Skip to main content

A simple Python resource lock to ensure only one process at a time is operating with a particular resource.

Project description

A simple Python resource lock to ensure only one process at a time is operating with a particular resource.

Singleton Usage

Singleton creates a file containing process information to ensure that the process that created the lock is still alive. The default location is in the .lock directory in the current working directory. If this directory does not exist, singleton will create it automatically.

Simple usage:

from quicklock import singleton

singleton('my-process') # This will ensure that only one of these is running at once
                        # The lock is released when the process that created the lock
                        # exits (successfully or quits unexpectedly)

# Intensive processing here

Specifying the lock directory:

from quicklock import singleton

singleton('my-process', dirname='/var/lock') # Now all lock files will be written to
                                             # /var/lock instead

# Intensive processing here

Contributing

Please feel free to create issues and submit pull requests. I want to keep this library as a simple collection of useful locking-related utilities.

License

The license is MIT, see the attached LICENSE file for more information.

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

quicklock-0.1.7.tar.gz (2.0 kB view details)

Uploaded Source

File details

Details for the file quicklock-0.1.7.tar.gz.

File metadata

  • Download URL: quicklock-0.1.7.tar.gz
  • Upload date:
  • Size: 2.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for quicklock-0.1.7.tar.gz
Algorithm Hash digest
SHA256 f404efc3115be8f92ab0b5f34b4efda5d5d14c03a567ebe910957826ac4a0897
MD5 7d39532ce909474a2cbd4cbe854a6502
BLAKE2b-256 79a63094ac123a12cc2dd4873701497de62911b3c2bb0d85c4b3ae74ae687530

See more details on using hashes here.

Supported by

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