[New-bugs-announce] [issue15634] synchronized decorator for the threading module
Juan Javier
report at bugs.python.org
Mon Aug 13 10:04:28 CEST 2012
New submission from Juan Javier:
I think it will be useful to have a decorator like this one on the threading module:
def synchronized(func):
"""A decorator to make a function execution synchronized.
Examples:
@synchronized
def foo():
pass
class Foo:
def __init__(self):
self.__syncdata = None
@property
def syncdata(self):
return self.__syncdata
@syncdata.setter
@synchronized
def syncdata(self, value):
self.__syncdata = value
"""
if not hasattr(func, "__lock"):
func.__lock = threading.Lock()
def _synchronized(*args, **kwds):
with func.__lock:
func(*args, **kwds)
_synchronized.__doc__ = func.__doc__
return _synchronized
What do you think?
----------
components: Library (Lib)
messages: 168071
nosy: jjdominguezm
priority: normal
severity: normal
status: open
title: synchronized decorator for the threading module
type: enhancement
versions: Python 3.4
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15634>
_______________________________________
More information about the New-bugs-announce
mailing list