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
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 details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ctrlchandler-0.10.tar.gz.
File metadata
- Download URL: ctrlchandler-0.10.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
88d7c72c0e941f272d15047e6daffa838e84d8c8599e3b79962c1bb13cc1a227
|
|
| MD5 |
1bd91183d9639782d5c1e3c01b2d9be6
|
|
| BLAKE2b-256 |
cb5b06bc9f4a6d0e37e153b2fcfe732937fa3622aea17b76874f896a0f01b6d1
|
File details
Details for the file ctrlchandler-0.10-py3-none-any.whl.
File metadata
- Download URL: ctrlchandler-0.10-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e8409908a9322764fdf2a5ec54a1e165e913090f3bff20032598611bd07ddd45
|
|
| MD5 |
ca0657fb7125306ec7ba8da6b323e843
|
|
| BLAKE2b-256 |
d3789e816d71ee461b8fca559de785e3af6c5c6e56af9af89a7d066069706fd0
|