¡@

Home 

python Programming Glossary: self._lock

How to make built-in containers (sets, dicts, lists) thread safe?

http://stackoverflow.com/questions/13610654/how-to-make-built-in-containers-sets-dicts-lists-thread-safe

thread safe def __init__ self args kwargs # Create a lock self._lock Lock # Call the original __init__ super LockedSet self .__init__.. LockedSet self .__init__ args kwargs def add self elem self._lock.acquire try super LockedSet self .add elem finally self._lock.release.. try super LockedSet self .add elem finally self._lock.release def remove self elem self._lock.acquire try super LockedSet..