Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

Ensure a single process is running. Using lockfile and process checking.

Project description


|image| |image| |Documentation Status| |Updates|

Ensure a single process is running. Using lockfile and process checking.


Sometime you want that a process runs at most once, for example a
scheduled cron job that should always finish before starting again. That
was my case.


.. code:: bash

pip install sing


Normally, at the beginning of the file, you may want to declare, that
you want to be the single instance:

.. code:: python

from sing import single

assert single()

That's it, for most of the use case, you don't need anything else. The
assert will fail if the lock is already taken.

This uses a pid lockfile, in a temporary folder to ensure this. More on
that in ````

You may want to grant all the lock from the same process, in that case
you'll need.

.. code:: python

assert single(allow_all_from_this_process=True)

You may have different subsections, and you want to have different
locks, even if you're on the same process, both of them will return

.. code:: python


Finally, if a PID file is there, but the process died, you may want to
grant the lock. Use the ``ensure_process_running`` to check it.


- Free software: MIT license
- Documentation:


This package was created with
`Cookiecutter <>`__ and the
`audreyr/cookiecutter-pypackage <>`__
project template.

Lot of inspiration comes from
`pycontribs/tendo <>`__ that serves
the same purpose. I needed PID file, and allow same process grants, so I
made this package.

.. |image| image::
.. |image| image::
.. |Documentation Status| image::
.. |Updates| image::


0.1.0 (2018-02-25)

* First release on PyPI.

Project details

Download files

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

Files for sing, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size sing-0.1.1.tar.gz (9.6 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page