global threading.Lock not locking correctly?

Afanasiy abelikov72 at hotmail.com
Tue Feb 4 10:27:21 EST 2003


On Tue, 04 Feb 2003 15:11:15 GMT, Alex Martelli <aleax at aleax.it> wrote:

>Afanasiy 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
>>       
>>       lock.acquire
>>       
>>       visitors += 1
>>       if visitors > 1:
>>         print 'OOPS!'+str(visitors),
>>       else:
>>         print '.',
>>       visitors -= 1
>>       
>>       lock.release
>
>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 mailing list