Skip to main content

Daemon python process

Class Daemon allow to run python script like a daemon process.

To run a process as a daemon you must inherit from Daemon. Daemon has abstractmethod daemon. The code to run in the background must be placed in the daemon method.

The Daemon class constructor contains the required parameter pid_file which is the path to the storage location of the file with the daemon's pid. Also the constructor also has parameters for determining the path for the stdout and stderr files.

start method used to run daemon. stop method used to stop daemon. restart method used to restart daemon.

Process to background (note)

Calling setsid is usually one of the steps a process goes through when becoming a so called daemon process. (We are talking about Linux/Unix OS). With setsid the association with the controlling terminal breaks. This means that the process will be NOT affected by a logout. There are other way how to survive a logout, but the purpose of this 'daemonizing' process is to create a background process as independent from the outside world as possible. That's why all inherited descriptors are closed; cwd is set to an appropriate directory, often the root directory; and the process leaves the session it was started from. A double fork approach is generally recommended. At each fork the parent exits and the child continues. Actually nothing changes except the PID, but that's exactly what is needed here. First fork before the setsid makes sure the process is not a process group leader. That is required for a succesfull setsid. The second fork after the setsid makes sure that a new association with a controlling terminal won't be started merely by opening a terminal device.

Source stackoverflow

Краткая суть в том что необходимо создать копию процесса через fork, сделать его максимально независимым от внешнего мира и создание еще одной копии процесса через fork, это делается для смена PID.

Metadata

Release files for daemon-process 0.9.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for daemon-process 0.9.2
File Size Uploaded Provenance
daemon-process-0.9.2.tar.gz 4.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for daemon-process 0.9.2
File Interpreter ABI Platform
daemon_process-0.9.2-py3-none-any.whl Python 3 none any Details

Total release size: 9.5 kB

Release files / daemon-process-0.9.2.tar.gz

Download URL daemon-process-0.9.2.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
ea8e2cb1f6471985b67fb1735653aaa7eeca1906ac396149de7907949755732b
BLAKE2b-256 checksum
How to use checksums
2dcc6436c29608b6c90296a129002b24a6b3ab6b4464d9166f9b292c11f8e476
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.8.1

Release files / daemon_process-0.9.2-py3-none-any.whl

Download URL daemon_process-0.9.2-py3-none-any.whl
Size 5.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
120e4765de038efb1d45904a9fa99aaede4a47d363eb08f0d1cf8b3ea006557f
BLAKE2b-256 checksum
How to use checksums
fc6d843486a53eb60c3b7ef7d97e0ca0a10ab7df12016ffc84c756a0b03ec7fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.8.1

Security for daemon-process 0.9.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.9.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page