{"id":16738255,"url":"https://github.com/tonyseek/python-orphanage","last_synced_at":"2025-04-10T12:53:46.375Z","repository":{"id":52704208,"uuid":"131389197","full_name":"tonyseek/python-orphanage","owner":"tonyseek","description":"Let child processes suicide if they became orphans.","archived":false,"fork":false,"pushed_at":"2021-04-20T17:41:56.000Z","size":82,"stargazers_count":12,"open_issues_count":4,"forks_count":2,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-24T11:38:41.553Z","etag":null,"topics":["orphan-prevention","process-management","python"],"latest_commit_sha":null,"homepage":"https://python-orphanage.readthedocs.io/","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/tonyseek.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}},"created_at":"2018-04-28T08:18:41.000Z","updated_at":"2021-03-31T08:57:25.000Z","dependencies_parsed_at":"2022-08-21T19:00:30.190Z","dependency_job_id":null,"html_url":"https://github.com/tonyseek/python-orphanage","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tonyseek%2Fpython-orphanage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tonyseek%2Fpython-orphanage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tonyseek%2Fpython-orphanage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tonyseek%2Fpython-orphanage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tonyseek","download_url":"https://codeload.github.com/tonyseek/python-orphanage/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247962460,"owners_count":21024862,"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":["orphan-prevention","process-management","python"],"created_at":"2024-10-13T00:29:50.840Z","updated_at":"2025-04-10T12:53:46.355Z","avatar_url":"https://github.com/tonyseek.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"|Build Status| |Coverage Status| |PyPI Version|\n\norphanage\n=========\n\nLet child processes in Python suicide if they became orphans.\n\nInstallation\n------------\n\n.. code-block:: bash\n\n    pip install orphanage\n\nDon't forget to put it in ``setup.py`` / ``requirements.txt``.\n\n\nUsage\n-----\n\n.. code-block:: python\n\n    from orphanage import exit_when_orphaned\n\n    exit_when_orphaned()\n\n\nMotivation\n----------\n\nSome application server softwares (e.g. Gunicorn_) work on a multiple-process\narchitect which we call the master-worker model. They must clean up the worker\nprocesses if the master process is stopped, to prevent them from becoming\norphan processes.\n\nIn the gevent-integration scene, the worker processes of Gunicorn poll their\n``ppid`` in an user thread (a.k.a greenlet) to be orphan-aware. But the user\nthread may be hanged once the master process crashed because of the blocked\nwriting on a pipe, the communicating channel between master process and\nworker processes.\n\nWe want to perform this ``ppid`` polling in a real kernel thread. That is the\nintent of this library.\n\n\nPrinciple\n---------\n\nThis library spawns an internal thread to poll the ``ppid`` at regular\nintervals (for now it is one second). Once the ``ppid`` changed, the original\nparent process should be dead and the current process should be orphaned. The\ninternal thread will send ``SIGTERM`` to the current process.\n\nIn the plan, the ``prctl`` \u0026 ``SIGHUP`` pattern may be introduced in Linux\nplatforms to avoid from creating threads. For now, the only supported strategy\nis the ``ppid`` polling, for being portable.\n\n\nAlternatives\n------------\n\nCaoE_ is an alternative to this library which developed by the Douban Inc. It\nuses ``prctl`` and a twice-forking pattern. It has a pure Python implementation\nwithout any C extension compiling requirement. If you don't mind to twist the\nprocess tree, that will be a good choice too.\n\n\nContributing\n------------\n\nIf you want to report bugs or request features, please feel free to open\nissues on GitHub_.\n\nOf course, pull requests are always welcome.\n\n.. _Gunicorn: https://github.com/benoitc/gunicorn\n.. _CaoE: https://github.com/douban/CaoE\n.. _GitHub: https://github.com/tonyseek/python-orphanage/issues\n\n.. |Build Status| image:: https://travis-ci.org/tonyseek/python-orphanage.svg?branch=master\n   :target: https://travis-ci.org/tonyseek/python-orphanage\n   :alt: Build Status\n.. |Coverage Status| image:: https://coveralls.io/repos/github/tonyseek/python-orphanage/badge.svg?branch=master\n   :target: https://coveralls.io/github/tonyseek/python-orphanage?branch=master\n   :alt: Coverage Status\n.. |PyPI Version| image:: https://img.shields.io/pypi/v/orphanage.svg\n   :target: https://pypi.org/project/orphanage/\n   :alt: PyPI Version\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftonyseek%2Fpython-orphanage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftonyseek%2Fpython-orphanage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftonyseek%2Fpython-orphanage/lists"}