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)
signal.pause()
The output from the python process after sending the USR1 signal twice:
$ python example.py [20785]: argv: ['example.py'] Reloading process! [20785]: argv: ['example.py', 'reloaded'] Reloading process! [20785]: argv: ['example.py', 'reloaded', 'reloaded']
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyexec-1.1.1.tar.gz
(2.2 kB
view hashes)
Built Distribution
Close
Hashes for pyexec-1.1.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7a3d62775fd1272d78e63075928f89ef2d8460d99e641670c013e9efc810f37 |
|
MD5 | aa5c84645dc55687535b61fdcf2db570 |
|
BLAKE2b-256 | 531df544585b8da26e1736e9736d6a0341542ff9bdbd5a9a89cc3ce3bc75d70b |