synchronized method
Max Ischenko
max at ucmg.com.ua.remove.it
Tue Feb 10 02:38:20 EST 2004
Hi,
I wrote simple implementation of the "synchronized" methods (a-la Java),
could you please check if it is OK:
def synchronized(method):
"""
Guards method execution, similar to Java's synchronized keyword.
The class which uses this method, is required to have a
L{threading.Lock} primitive as an attribute named 'lock'.
"""
def wrapper(self, *args):
self.lock.acquire()
try:
return method(self, *args)
finally:
self.lock.release()
return wrapper
...I'm no big thread expert
tia.
... The problem is not that there are problems. The problem is expecting
otherwise and thinking that having problems is a problem.
-- Theodore Rubin
More information about the Python-list
mailing list