global threading.Lock not locking correctly?
abelikov72 at hotmail.com
Tue Feb 4 16:27:21 CET 2003
On Tue, 04 Feb 2003 15:11:15 GMT, Alex Martelli <aleax at aleax.it> wrote:
>> # My logic tells me this should never print 'OOPS', yet it does.
>> # Can someone tell me why? (P.S. this is simplified example code)
>> import threading, time
>> class testthread(threading.Thread):
>> def run(self):
>> for x in range(40):
>> global lock
>> global visitors
>> visitors += 1
>> if visitors > 1:
>> print 'OOPS!'+str(visitors),
>> print '.',
>> visitors -= 1
>You're not CALLING the acquire and release methods, just
>MENTIONING them. use lock.acquire() and lock.release().
Hahaha, damnit! That's from too much Delphi...
I wish I could toggle such things to be 'warnings'.
Or does PyChecker also check for this?
More information about the Python-list