Skip to main content

Simple decorators to support synchronized methods

Project description

Introduction

https://secure.travis-ci.org/pyrenees/plone.synchronize.png

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.4 (2020-04-22)

New features:

  • Drop Python 2.6 support. Support 2.7, 3.5-3.8, PyPy2/3. Added tox for local testing. [maurits] (#2)

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

plone.synchronize-1.0.4.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

plone.synchronize-1.0.4-py2.py3-none-any.whl (4.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file plone.synchronize-1.0.4.tar.gz.

File metadata

  • Download URL: plone.synchronize-1.0.4.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/2.7.17

File hashes

Hashes for plone.synchronize-1.0.4.tar.gz
Algorithm Hash digest
SHA256 955be1fb52f0ed1ad132181a7537287940706655d5ad41e9c7aa248246b6fa57
MD5 974e22316fded6174e4a52df999172f2
BLAKE2b-256 2c2c1dabf7078e57c6ba63822a2497004515c03581a0ad485be63056f1943c10

See more details on using hashes here.

File details

Details for the file plone.synchronize-1.0.4-py2.py3-none-any.whl.

File metadata

  • Download URL: plone.synchronize-1.0.4-py2.py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/2.7.17

File hashes

Hashes for plone.synchronize-1.0.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 e53c02229fe692b16b7104fe8c44a4c032543264cee2079fdee4a6fa781c261f
MD5 e8574e3428184926215df2ee52c00a9d
BLAKE2b-256 f2f4ba6bc14f9cf57885bcd63c96758a2b80dfce5a8c14cd689ff3192fa167c6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page