Simple decorators to support synchronized methods
Project description
Introduction
This package provides a simple decorator to help synchronize methods across threads, to avoid problems of concurrent access.
It can be used like this:
from threading import Lock from plone.synchronize import synchronized class StupidStack(object): _elements = [] # not thread safe _lock = Lock() @synchronized(_lock) def push(self, item): self._elements.append(item) @synchronized(_lock) def pop(self): last = self._elements[-1] del self._elements[-1] return last
The decorator takes care of calling lock.acquire() just before the method is executed, and lock.release() just after. If an exception is raised in the method, the lock will still be released.
Changelog
1.0.3 (2018-03-10)
Bug fixes:
Release it as a wheel as well as an egg. [gforcada]
1.0.2 (2016-11-01)
New features:
Test Python 3 compatibility. [datakurre]
1.0.1 - 2011-05-20
Add license metadata. [davisagli]
1.0 - 2011-04-30
No changes
1.0b1 - 2009-03-30
Initial release
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for plone.synchronize-1.0.3-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a773bfebc9ee388637655dc0d167e4183c50629b64e95cf42f7c0aa1881e453 |
|
MD5 | f9263f89aa60aca468e9949fbc8ef2eb |
|
BLAKE2b-256 | 6c729fa96ef12adda40b038e9cebaf4234d0db6cf4f149006c76561ae80c3f85 |