SMP, GIL and Threads
Peter Hansen
peter at engcorp.com
Fri Dec 16 14:26:46 EST 2005
catsup wrote:
> The accessing thread takes command requests off a queue, every
> half-second, placed there by an altogether different thread, and does a
> lookup on this same dictionary before performing this command:
>
> def run_thread(self):
> while( not self.terminate ):
> cmd = self.cmdQueue.get(False)
> agentInfo = self.agentByIVRSeq[cmd[0]]
> self.performCmd(cmd,agentInfo)
> sleep(.5)
You can guarantee that there will always be exactly one item available
in the Queue for this thread to pull out? Or is this a heavily edited
example, with the required "try/except Queue.Empty" handling removed for
tender minds? :-)
(Note the "exactly one", too, since having either fewer or more will be
a problem for the above code.)
-Peter
More information about the Python-list
mailing list