Async serial communication/threads sharing data

Paul Rubin http
Sat Mar 21 21:57:56 CET 2009


Nick Timkovich <prometheus235 at gmail.com> writes:
> My main issue is with how to
> exchange data between different threads; can I just do something like
> have a global list of messages, appending, modifying, and removing as
> needed?  Does the threading.Lock object just prevent every other
> thread from running, or is it bound somehow to a specific object (like
> my list)?

The favored approach to this is to use the Queue module, which gives a
thread-safe double ended queue.  This is cleaner than messing with
lower level synchronization primitives like Lock.  You use Queues as
communications channels between threads.



More information about the Python-list mailing list