{"id":15569215,"url":"https://github.com/mosquito/python-pidfile","last_synced_at":"2025-10-02T23:35:05.622Z","repository":{"id":53338615,"uuid":"51740644","full_name":"mosquito/python-pidfile","owner":"mosquito","description":null,"archived":false,"fork":false,"pushed_at":"2023-03-24T13:32:36.000Z","size":32,"stargazers_count":25,"open_issues_count":7,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-11T19:02:36.099Z","etag":null,"topics":["kill","pid","pidfile","python","system"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mosquito.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-02-15T08:20:24.000Z","updated_at":"2024-10-07T16:43:16.000Z","dependencies_parsed_at":"2024-06-19T01:22:13.194Z","dependency_job_id":null,"html_url":"https://github.com/mosquito/python-pidfile","commit_stats":{"total_commits":32,"total_committers":4,"mean_commits":8.0,"dds":0.375,"last_synced_commit":"7426db1cb57f4373b924ae5754ef2b124c1d8b3d"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mosquito%2Fpython-pidfile","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mosquito%2Fpython-pidfile/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mosquito%2Fpython-pidfile/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mosquito%2Fpython-pidfile/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mosquito","download_url":"https://codeload.github.com/mosquito/python-pidfile/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235048986,"owners_count":18927716,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["kill","pid","pidfile","python","system"],"created_at":"2024-10-02T17:22:46.367Z","updated_at":"2025-10-02T23:35:05.237Z","avatar_url":"https://github.com/mosquito.png","language":"Python","readme":"Python PIDFile\n==============\n\n.. image:: https://github.com/mosquito/python-pidfile/actions/workflows/tests.yml/badge.svg\n   :target: https://github.com/mosquito/python-pidfile/actions/workflows/tests.yml\n   :alt: Github Actions\n\n.. image:: https://img.shields.io/pypi/v/python-pidfile.svg\n   :target: https://pypi.python.org/pypi/python-pidfile/\n   :alt: Latest Version\n\n.. image:: https://img.shields.io/pypi/wheel/python-pidfile.svg\n   :target: https://pypi.python.org/pypi/python-pidfile/\n   :alt: round wheels\n\n.. image:: https://img.shields.io/pypi/pyversions/python-pidfile.svg\n   :target: https://pypi.python.org/pypi/python-pidfile/\n   :alt: Python versions\n\n.. image:: https://img.shields.io/pypi/l/python-pidfile.svg\n   :target: https://pypi.python.org/pypi/python-pidfile/\n   :alt: License\n\n.. image:: https://coveralls.io/repos/github/CostantinoGrana/python-pidfile/badge.svg?branch=master\n   :target: https://coveralls.io/github/CostantinoGrana/python-pidfile?branch=master\n   :alt: Coverage Status\n\n\nPython context manager for managing pid files. Example usage:\n\n.. code-block:: python\n\n    import pidfile\n    import time\n\n    print('Starting process')\n    try:\n        with pidfile.PIDFile(\"/var/run/example.pid\"):\n            print('Process started')\n            time.sleep(30)\n    except pidfile.AlreadyRunningError:\n        print('Already running.')\n\n    print('Exiting')\n\nThe context manager will take care of verifying the existence of a pid file,\ncheck its pid to see if it's alive, check the command line (which should be `\u003csomething\u003e/\u003cpython name\u003e`), and\nif all the conditions are met, rise a `pidfile.AlreadyRunningError` exception.\n\n`PIDFile()` defaults to `pidfile` for the file name, but it's possible to specify another, e.g. `PIDFile('foobar.pid')`.\n\n\nUnder the hood\n--------------\n\nThe algorithm of the library is very simple, at startup, a file is created,\nand after checking that another instance of the program is not running, the\ncurrent process ID is written to it.\n\nThe check works as follows:\n\n* If the file does not exist, then the check is passed.\n* An identifier is written in the file, it is read and checked that a\n  process running with such an identifier exists, and has the same command line.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmosquito%2Fpython-pidfile","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmosquito%2Fpython-pidfile","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmosquito%2Fpython-pidfile/lists"}