Skip to main content

File-based locks for Python for Linux and Windows

Project description

import locket

# Wait for lock
with locket.lock_file("path/to/lock/file"):
    perform_action()

# Raise error if lock cannot be acquired immediately
with locket.lock_file("path/to/lock/file", timeout=0):
    perform_action()

# Raise error if lock cannot be acquired after thirty seconds
with locket.lock_file("path/to/lock/file", timeout=30):
    perform_action()

# Without context managers:
lock = locket.lock_file("path/to/lock/file")
try:
    lock.acquire()
    perform_action()
finally:
    lock.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

locket-0.1.0.tar.gz (1.6 kB view details)

Uploaded Source

File details

Details for the file locket-0.1.0.tar.gz.

File metadata

  • Download URL: locket-0.1.0.tar.gz
  • Upload date:
  • Size: 1.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for locket-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d09df6d9f55dce5c76d46226032c6536f768a3d2aa1903b98ba2becfe3cb5e9d
MD5 f18eaf932cdbd6306fc738f84908a37b
BLAKE2b-256 83ec96ef2a7e1e19e7d033cc74501d4526250143cd008c46313136f27b7f498d

See more details on using hashes here.

Supported by

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