Name | graceful-sigterm JSON |
Version |
0.1.3
JSON |
| download |
home_page | None |
Summary | Receive the kill signal from the operating system and gracefully wait for the worker thread to end. |
upload_time | 2024-10-18 10:25:15 |
maintainer | Huang YongSi |
docs_url | None |
author | Huang YongSi |
requires_python | None |
license | MIT |
keywords |
sigterm
kill python
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# graceful-sigterm
Receive the kill signal from the operating system and gracefully wait for the worker thread to end.
Note: The package name is `graceful-sigterm` but the module name is `sigterm` for short.
## Install
```
pip install graceful-sigterm
```
## Usage Example 1
*example1.py*
```
import time
import signal
import sigterm
def worker():
print("Press Ctrl+C, and wait 5 seconds to stop...")
while not sigterm.is_stopped():
print(".", end="", flush=True)
sigterm.wait_until_stop(timeout=1)
print("")
for i in range(5):
print("x", end="", flush=True)
time.sleep(1)
def main():
sigterm.setup()
sigterm.setup(signal.SIGINT)
sigterm.register_worker(worker)
sigterm.execute()
if __name__ == "__main__":
main()
```
*output*
```
test@test sigterm % python example1.py
Press Ctrl+C, and wait 5 seconds to stop...
....^C
xxxxx%
```
## Releases
### 0.1.0
- 版本首发。
### 0.1.1
- 文档修改。
### 0.1.2
- 修正主线程中长时间待子线程结束导致无法拦截信号的问题。
### 0.1.3
- 更友好的提示信息。
Raw data
{
"_id": null,
"home_page": null,
"name": "graceful-sigterm",
"maintainer": "Huang YongSi",
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "sigterm, kill python",
"author": "Huang YongSi",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/18/f6/9d2c26aec0bd25c014ad26e75d266c2c0a87a16cb623cc77c46bcb8409f0/graceful_sigterm-0.1.3.tar.gz",
"platform": null,
"description": "# graceful-sigterm\r\n\r\nReceive the kill signal from the operating system and gracefully wait for the worker thread to end.\r\n\r\nNote: The package name is `graceful-sigterm` but the module name is `sigterm` for short.\r\n\r\n## Install\r\n\r\n```\r\npip install graceful-sigterm\r\n```\r\n\r\n## Usage Example 1\r\n\r\n*example1.py*\r\n\r\n```\r\nimport time\r\nimport signal\r\nimport sigterm\r\n\r\n\r\ndef worker():\r\n print(\"Press Ctrl+C, and wait 5 seconds to stop...\")\r\n while not sigterm.is_stopped():\r\n print(\".\", end=\"\", flush=True)\r\n sigterm.wait_until_stop(timeout=1)\r\n print(\"\")\r\n for i in range(5):\r\n print(\"x\", end=\"\", flush=True)\r\n time.sleep(1)\r\n\r\n\r\ndef main():\r\n sigterm.setup()\r\n sigterm.setup(signal.SIGINT)\r\n sigterm.register_worker(worker)\r\n sigterm.execute()\r\n\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n```\r\n\r\n*output*\r\n\r\n```\r\ntest@test sigterm % python example1.py\r\nPress Ctrl+C, and wait 5 seconds to stop...\r\n....^C\r\nxxxxx% \r\n```\r\n\r\n\r\n## Releases\r\n\r\n### 0.1.0\r\n\r\n- \u7248\u672c\u9996\u53d1\u3002\r\n\r\n### 0.1.1\r\n\r\n- \u6587\u6863\u4fee\u6539\u3002\r\n\r\n### 0.1.2\r\n\r\n- \u4fee\u6b63\u4e3b\u7ebf\u7a0b\u4e2d\u957f\u65f6\u95f4\u5f85\u5b50\u7ebf\u7a0b\u7ed3\u675f\u5bfc\u81f4\u65e0\u6cd5\u62e6\u622a\u4fe1\u53f7\u7684\u95ee\u9898\u3002\r\n\r\n### 0.1.3\r\n\r\n- \u66f4\u53cb\u597d\u7684\u63d0\u793a\u4fe1\u606f\u3002\r\n\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Receive the kill signal from the operating system and gracefully wait for the worker thread to end.",
"version": "0.1.3",
"project_urls": null,
"split_keywords": [
"sigterm",
" kill python"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "41aeae5b13bc93b3d688b48929166621875f34b4169e33933d85b51ac573ad19",
"md5": "bb7370e42400da8355a4a70b29226dff",
"sha256": "40c885878431fb99ff6e191ec427e3cd81752481027ebf0974c41954920ea1ce"
},
"downloads": -1,
"filename": "graceful_sigterm-0.1.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "bb7370e42400da8355a4a70b29226dff",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 4294,
"upload_time": "2024-10-18T10:25:14",
"upload_time_iso_8601": "2024-10-18T10:25:14.076363Z",
"url": "https://files.pythonhosted.org/packages/41/ae/ae5b13bc93b3d688b48929166621875f34b4169e33933d85b51ac573ad19/graceful_sigterm-0.1.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "18f69d2c26aec0bd25c014ad26e75d266c2c0a87a16cb623cc77c46bcb8409f0",
"md5": "d719fc53c30ed577fa65d8865660545d",
"sha256": "b41ea7b6d979f7599d5e21ae6b845374406af4cda95f29769b4bd2c7a1aaab1b"
},
"downloads": -1,
"filename": "graceful_sigterm-0.1.3.tar.gz",
"has_sig": false,
"md5_digest": "d719fc53c30ed577fa65d8865660545d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 4518,
"upload_time": "2024-10-18T10:25:15",
"upload_time_iso_8601": "2024-10-18T10:25:15.220576Z",
"url": "https://files.pythonhosted.org/packages/18/f6/9d2c26aec0bd25c014ad26e75d266c2c0a87a16cb623cc77c46bcb8409f0/graceful_sigterm-0.1.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-18 10:25:15",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "graceful-sigterm"
}