Skip to main content

Like atexit but for ctrl+c

Project description

Like atexit but for ctrl+c

Tested against Windows 10 / Python 3.10 / Anaconda

pip install ctrlchandler

# atexit

import atexit

def printx(bu=12, ba=3223):

    print(bu, ba)

    print('ciao')

atexit.register(printx, bu='nice', ba='ba')

exit()

nice ba

ciao

Process finished with exit code 0
from ctrlchandler import set_console_ctrl_handler





def printx(bu=12, ba=3223):

    print(bu, ba)

    print('ciao')





set_console_ctrl_handler(returncode=1, func=printx, bu=12011, ba=32231111)

while True:

    pass





After pressing ctrl+c

^C12011 32231111

ciao

Process finished with exit code 1

Project details


Release history Release notifications | RSS feed

This version

0.10

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ctrlchandler-0.10.tar.gz (4.0 kB view hashes)

Uploaded Source

Built Distribution

ctrlchandler-0.10-py3-none-any.whl (5.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page