I am using PySerial (a Python API for serial communication) to send AT commands to a Nokia phone via bluetooth.

```
import serial
com = serial.Serial()
com.port = 19
com.timeout = 0 #also tried a timeout value greater than 0.
try:
    com.open()
    # at this point I turn off the phone.
    com.write("AT\r\n")
    print com.readlines()
except SerialException, e:
    print e

```

Just after I open() the com, I turn off the phone. Then, I write("AT\r\n"). At this point, the function blocks and the runtime hangs.

Do you have any solution?