[Twisted-Python] serial communication - getting started

Itamar Turner-Trauring itamar at itamarst.org
Mon Oct 21 05:45:35 MDT 2013


On 10/21/2013 07:35 AM, Robert Voigtländer wrote:
> def SerialInit():
> ...
>     reactor.run()
>
>
> thread.start_new_thread(SerialInit())
>
> if __name__ == '__main__':
>     print("-----")
>     s.write('123456789')
>     #s.write("\n")
>
1. Twisted is not thread-safe, so you can't call methods on the protocol 
from another thread.

2. As a result, you're probably best off not using threads at all.

3. A reasonable place for the write() might be in your Protocol's 
connectionMade method.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20131021/3e17e607/attachment-0002.html>


More information about the Twisted-Python mailing list