Skip to main content

Simple but powerful signal handling to process OS signals in python

Project description

listen

Simple but powerful signal handling to process OS signals in python

##Example Usage:

import listen
import subprocess

Instanciate SignalHandler

sig_hand = listen.SignalHandler()

Start external process

external_process = subprocess.Popen(['sh', '-c', 'sleep 30'])

Register some signal handlers to kill external process on SIGINT (ctrl-c)

kill_event = sig_hand.reg_on_status(external_process.kill)

Wait for external process

external_process.wait()

Press ctrl-c to send SIGINT or alternatively use the following to unregister the event

sig_hand.del_status_event(kill_event)

For a more detailed example including interaction with bash please see the tests/example.py and tests/external_process.bash

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 listen, version 0.2.1
Filename, size File type Python version Upload date Hashes
Filename, size listen-0.2.1-py3-none-any.whl (9.3 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size listen-0.2.1.tar.gz (6.5 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page