[Twisted-Python] Help for Twisted + Thread + Message Queue

Stefano Danzi s.danzi at hawai.it
Thu Oct 3 10:57:58 MDT 2013


Hi!!

I have to write a little python program to manage a serial port radio modem.
I have to send some AT commands and read resposes. This is not a problem,
twisted examples are enough.

...but I have a situation that makes things complicated:

Anytime the modem can send back to serial port a line starting with "++"...
I have to catch it and do some analysis that could take a long time.

How to solve????????????????

I have found only this manner:

  - a thread continuously read from serial port.
  - if it receive a line stanting with "++" put it in a queue (I could 
name it "unexpected-queue")
  - this thread also check for commands on another queue (commands-queue)
  - if there are something on command-queue it send command to serial 
port an put
    replies on another queue (replies-queue)
  - Another thread loop to check unexpected-queue and do something if 
there are messages.
  - main program sent commands to command-queue and read replies from 
replies-queue

Does anyone have better ideas or suggestions?



More information about the Twisted-Python mailing list