Queue: Which form is better/more Pythonic?
Jeff Hinrichs
jlh at cox.net
Sat Feb 22 17:05:27 EST 2003
> Unfortunately, GUI/thread synchronization does require "busy loops"
> (polling) in most cases (few GUIs have good integration with
> multiple threads in their main loops). There are still right and
> wrong ways to do it, and the Cookbook has a good example by Jacob
> Hallén which I suggest you check.
>
Thanks Alex, I saw the example in the cookbook and I will be referring
back to it. In learning about threading, I wanted to minimize what
was going on so that I could learn threading better before worrying
about the wonderful UI integration part.
On another note about the cookbook example.. Jacob uses a simple
variable to signal the ThreadedClient to shutdown. From what I've
read so far, it would appear that the variable should be locked
or a queue should be used. The reason being, if updating a shared
variable you should lock it prior to acting on it, correct? If I used a
queue object that locking will be done for me automagically. Or is
this shared variable ok to use with out a lock because of its
simplicity/single purpose? I realize that I could set locks on
the shutdown flag in the cookbook example, but I was thinking it
would be better for me to stick with queue objects so I don't do
something boneheaded wrt to locks.
thanks,
Jeff
More information about the Python-list
mailing list