global threading.Lock not locking correctly?
Laura Creighton
lac at strakt.com
Tue Feb 4 10:26:23 EST 2003
More information about the Python-list mailing list
Tue Feb 4 10:26:23 EST 2003
- Previous message (by thread): global threading.Lock not locking correctly?
- Next message (by thread): global threading.Lock not locking correctly?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> # 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 > > #time.sleep(0.01) #less OOPS of course > > visitors = 0 > lock = threading.Lock() > > for i in range(10): > testthread().start() > > -- > http://mail.python.org/mailman/listinfo/python-list You want lock.aquire() and lock.release() Laura
- Previous message (by thread): global threading.Lock not locking correctly?
- Next message (by thread): global threading.Lock not locking correctly?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list