Need help in updating a global variable by a thread

dedalusenator at dedalusenator at
Wed Oct 17 20:48:08 CEST 2007

Hello Folks,

My first posting here and I am a stuck in figuring out the exact way
to update a global variable from within a function that doesnt return
any value (because the function is a target of the thread and I dont
know how exactly return would work in such a case). I am sure I am
missing something very fundamental here. The essential pieces of my
code that cause the problem would be something like this:
lookuptab = {'':'Bangkok','':'Sydney'}

results = {}

for val in lookuptab.values():

def testt(loc):
       global results
       results[loc] = 1
       return results[loc]

for x in lookuptab.values():
      thread = threading.Thread(target=testt,args=(x))
print results

results contain 0 instead of 1. Any help clearing my block is greatly


More information about the Python-list mailing list