# Like atexit but for ctrl+c
### Tested against Windows 10 / Python 3.10 / Anaconda
## pip install ctrlchandler
```python
# 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
```
```python
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
```
Raw data
{
"_id": null,
"home_page": "https://github.com/hansalemaos/ctrlchandler",
"name": "ctrlchandler",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "atexit,ctypes,kill,terminate",
"author": "Johannes Fischer",
"author_email": "<aulasparticularesdealemaosp@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/cb/5b/06bc9f4a6d0e37e153b2fcfe732937fa3622aea17b76874f896a0f01b6d1/ctrlchandler-0.10.tar.gz",
"platform": null,
"description": "\r\n# Like atexit but for ctrl+c\r\n\r\n\r\n\r\n### Tested against Windows 10 / Python 3.10 / Anaconda \r\n\r\n\r\n\r\n## pip install ctrlchandler\r\n\r\n\r\n\r\n\r\n\r\n```python\r\n\r\n# atexit\r\n\r\nimport atexit\r\n\r\ndef printx(bu=12, ba=3223):\r\n\r\n print(bu, ba)\r\n\r\n print('ciao')\r\n\r\natexit.register(printx, bu='nice', ba='ba')\r\n\r\nexit()\r\n\r\nnice ba\r\n\r\nciao\r\n\r\nProcess finished with exit code 0\r\n\r\n```\r\n\r\n\r\n\r\n```python\r\n\r\nfrom ctrlchandler import set_console_ctrl_handler\r\n\r\n\r\n\r\n\r\n\r\ndef printx(bu=12, ba=3223):\r\n\r\n print(bu, ba)\r\n\r\n print('ciao')\r\n\r\n\r\n\r\n\r\n\r\nset_console_ctrl_handler(returncode=1, func=printx, bu=12011, ba=32231111)\r\n\r\nwhile True:\r\n\r\n pass\r\n\r\n\r\n\r\n\r\n\r\nAfter pressing ctrl+c\r\n\r\n^C12011 32231111\r\n\r\nciao\r\n\r\nProcess finished with exit code 1\r\n\r\n```\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Like atexit but for ctrl+c",
"version": "0.10",
"split_keywords": [
"atexit",
"ctypes",
"kill",
"terminate"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d3789e816d71ee461b8fca559de785e3af6c5c6e56af9af89a7d066069706fd0",
"md5": "ca0657fb7125306ec7ba8da6b323e843",
"sha256": "e8409908a9322764fdf2a5ec54a1e165e913090f3bff20032598611bd07ddd45"
},
"downloads": -1,
"filename": "ctrlchandler-0.10-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ca0657fb7125306ec7ba8da6b323e843",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 5271,
"upload_time": "2023-04-09T02:22:12",
"upload_time_iso_8601": "2023-04-09T02:22:12.006676Z",
"url": "https://files.pythonhosted.org/packages/d3/78/9e816d71ee461b8fca559de785e3af6c5c6e56af9af89a7d066069706fd0/ctrlchandler-0.10-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "cb5b06bc9f4a6d0e37e153b2fcfe732937fa3622aea17b76874f896a0f01b6d1",
"md5": "1bd91183d9639782d5c1e3c01b2d9be6",
"sha256": "88d7c72c0e941f272d15047e6daffa838e84d8c8599e3b79962c1bb13cc1a227"
},
"downloads": -1,
"filename": "ctrlchandler-0.10.tar.gz",
"has_sig": false,
"md5_digest": "1bd91183d9639782d5c1e3c01b2d9be6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 3966,
"upload_time": "2023-04-09T02:22:14",
"upload_time_iso_8601": "2023-04-09T02:22:14.070945Z",
"url": "https://files.pythonhosted.org/packages/cb/5b/06bc9f4a6d0e37e153b2fcfe732937fa3622aea17b76874f896a0f01b6d1/ctrlchandler-0.10.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-04-09 02:22:14",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "hansalemaos",
"github_project": "ctrlchandler",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "ctrlchandler"
}