Locking access to all data members
gooli
egooli at gmail.com
Sun Jan 28 04:31:48 EST 2007
I have a class with a lot of attributes whose objects are accessed
from multiple threads. I would like to synchronize the access to all
the attributes, i.e. acquire a lock, return the value, release the
lock (in a finally clause).
Is there a way to do that without turning each attribute into a
property and manually wrapping each property with the locking code?
How about classes bound with SQLAlchemy? Is it possible to do that for
those too?
Example of a class I would like to wrap:
class Job(object):
def __init__(self, itemType):
self.id = self.idSequence
self.itemType = itemType
self.status = "waiting"
self.createDate = None
self.hostName = None
self.progress = 0
self.items = []
More information about the Python-list
mailing list