SMP, GIL and Threads
catsup
ramadon.rexx at gmail.com
Fri Dec 16 14:13:57 EST 2005
Yes. Iterating over a list that you concurrently update will
definately cause problems. That is not the type of "read" I am doing
in the application. My read is one key/value translation. Below is an
example of the operations I am performing to help clarify.
The update thread, running once every fifteen minutes, gathers updates
for the dictionary and applies them:
def run_thread(self):
while( not self.terminate ):
sleep(900)
for agentRec in self.agentListUpdates:
agentInfo = agentRec[1]
if agentRec[0] == 'a':
self.agentByIVRSeq[agentInfo.IVRSeq] = agentInfo #->
thread hangs here
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)
More information about the Python-list
mailing list