Need a better way to pause a thread

Marc mnations at airmail.net
Wed Jul 24 11:25:18 EDT 2002


Thanks Chris, and you hit upon something I've been wondering about for a
while. I've used queues before to do simple things like strings and
variables when I simple wanted to display or use something. But when I tried
to do whole commands, it got klunky. The only way I had found to do it was
putting the commands in a string and using eval() on the command on the
other side. This was too painful to use in large applications. However you
did it the following way:

> #now you can feed your thread with work:
> q.put( (time.sleep, 1) )
> q.put( (sys.stdout.write, "Hello its the thread speaking up") )

Basically it appears the format is the command placed in nested () with
things that would be passed thru as parameters being delimited by commas. Is
this a general format that will work for all commands, or is there a place I
can check the format? There are several examples of queues I've found but
none showing all the ways you can pass commands through.

Marc



More information about the Python-list mailing list