1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
from __future__ import with_statement
from threading import Lock
def synchronized(fun):
the_lock = Lock()
def fwrap(function):
def newFunction(*args, **kw):
with the_lock:
return function(*args, **kw)
return newFunction
return fwrap(fun)
|