Windows GUI - which way?

Jeff Shannon jeff at ccvcorp.com
Mon Mar 4 19:09:05 EST 2002


Spencer Ernest Doidge wrote:

> Thank you, Jeff.
> It happens that I want to do all this with scripts that are all under my
> control, so there is a lot of good news here in your answer.
> One further question: Should the two processes communicate with each other
> via mmap?

If you're controlling the scripts yourself, then you're probably better off using
threads rather than subprocesses.  In that case, there's no need to use mmap --
Queue.Queue will likely do everything that you need, and it's very easy to use.  Each
thread gets handed an input queue and an output queue when it's created.  It can
periodically check the input queue for any messages from the main thread, and can put
output messages in the output queue (which the main thread then retrieves and handles
appropriately).  What constitutes a "message" is entirely up to you -- it can be any
Python object.  For simple cases, it could be a string or an integer, which the thread
maps to some particular action (like aborting).  For more complex cases, it would
likely be an instance object, whose attributes carry whatever information you want to
convey.  (In my latest use of queues, the message object has a "command" attribute,
which is essentially the name of a method to call, and other attributes of the object
map to parameters for that method.)

Jeff Shannon
Technician/Programmer
Credit International





More information about the Python-list mailing list