Skip to main content

Pidfile featuring stale detection and file-locking, can also be used as context-manager or decorator

Project description

https://travis-ci.org/trbs/pid.svg?branch=master https://coveralls.io/repos/trbs/pid/badge.png Latest PyPI version Number of PyPI downloads

PidFile class featuring:

  • stale detection

  • pidfile locking (fcntl)

  • chmod (default is 0o644)

  • chown

  • custom exceptions

Context Manager

PidFile can be used as a context manager:

from pid import PidFile

with PidFile():
  do_something()

Decorator

PidFile can also be used a a decorator:

from pid.decorator import pidfile

@pidfile()
def main():
  pass

if __name__ == "__main__":
  main()

Exception Order

In default mode PidFile will try to acquire a file lock before anything else. This means that normally you get a PidFileAlreadyLockedError instead of the PidFileAlreadyRunningError when running a program twice.

If you just want to know if a program is already running its easiest to catch just PidFileError since it will capture all possible PidFile exceptions.

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

pid-1.1.0.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

pid-1.1.0-py2.py3-none-any.whl (5.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pid-1.1.0.tar.gz.

File metadata

  • Download URL: pid-1.1.0.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pid-1.1.0.tar.gz
Algorithm Hash digest
SHA256 590898b5bb20e85589605a0a5e124acb77ee84fa3c95910e5b81409defe3c1a5
MD5 343f20dfa18af6b452c6e4ee8fb3bfa3
BLAKE2b-256 a4c05200173e3dba219bb890da2ff9600da766667b2a7eeb5a7602ad9ddd04ca

See more details on using hashes here.

File details

Details for the file pid-1.1.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pid-1.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ac3c5aa6e99798e2018dc9c32782f76ae3e1d7c42f04c50746dfaf6ea87d5cf0
MD5 8d11d39760e3c0de08bc85b96895a38a
BLAKE2b-256 181b78c988741f197a9447ead816e7b44889f2024bd39d719080e8250c9fdb69

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