Skip to main content

Signal-triggered process reloader

Project description

Pyexec allows to setup signal handler, which will reload current process. This functionality might be used to restart application, e.g. when the code’s been changed, by sending an appropriate signal to the python process.

Exemplary usage:

import os
import pyexec
import signal
import sys

def handler():
    sys.stderr.write('Reloading process!\n')
    return sys.argv + ['reloaded']

sys.stderr.write('[%d]: argv: %r\n' % (os.getpid(), sys.argv))
pyexec.install(signal.SIGUSR1, handler)

The output from the python process after sending the USR1 signal twice:

$ python
[20785]: argv: ['']
Reloading process!
[20785]: argv: ['', 'reloaded']
Reloading process!
[20785]: argv: ['', 'reloaded', 'reloaded']

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 pyexec, version 1.1.1
Filename, size File type Python version Upload date Hashes
Filename, size pyexec-1.1.1-py2.py3-none-any.whl (3.6 kB) File type Wheel Python version 3.4 Upload date Hashes View
Filename, size pyexec-1.1.1.tar.gz (2.2 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page