Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Python client for locker lock server
Python
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

README.md

pylocker - python client for locker lock server

Allows to lock common resources across servers with sub-second precision in python.

Installation

Check out locker server page for server installation instructions.

Clone this repository to whatever place you keep your python modules.

Usage

from pylocker import Locker

# create locker server connection
locker = Locker("127.0.0.1", 4545)

# create lock object with some nice name
lock = locker.create_lock("fuu")
# acquire lock, wait for it for 500ms if it's taken
lock.acquire(500, 200)
# do whatever you need for up to 200ms
# and release lock
lock.release()

API

  • Importing:

    from pylocker import Locker
  • New connection:

    locker = Locker("127.0.0.1", 4545)
  • Lock creation:

    lock = locker.create_lock(name)
  • Acquiring lock:

    lock.acquire(wait, timeout)
    • wait - max time to wait for lock (in milliseconds).
    • timeout - max work time before release call or auto-release by timeout (in milliseconds).
  • Releasing lock:

    lock.release(panic = False)

If panic = True then LostLockException will be raised if time between acquire and release was more than timeout.

Usages:

  • @unfollowr - twitter bot to track people who unfollowed you
Something went wrong with that request. Please try again.