A "killable" sleep function for kthread
https://pypi.org/project/kthread/
From kthread's pypi site: Assuming that the thread is not blocked by an operating system call (such as sleep, accept, or recv), the thread will forcefully quit.
pip install kthread-sleep
import kthread
import sys
from kthread_sleep import sleep
def func():
try:
sleep(2000000)
finally:
sys.stdout.write("Greetings from Vice City!\n")
sys.stdout.flush()
t = kthread.KThread(target = func, name = "KillableThread1")
t.start()
sleep(.1)
print(t.is_alive())
t.kill()
sleep(.1)
print(t.is_alive())
True
Greetings from Vice City!
False
Metadata
Release files for kthread-sleep 0.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| kthread_sleep-0.11.tar.gz | 3.3 kB | Without provenance | Details for kthread_sleep-0.11.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kthread_sleep-0.11-py3-none-any.whl | Python 3 | none | any | Details for kthread_sleep-0.11-py3-none-any.whl |
Total release size: 7.9 kB
Release files / kthread_sleep-0.11.tar.gz
| Download URL | kthread_sleep-0.11.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eff9e2e8d46d37548c1a47e1e5ea09974a027a757d0611df06256cd24c5c63a8
|
|
BLAKE2b-256 checksum How to use checksums |
7066afa7508bfef9229f7d1b863edd20144d2f9ea25a1952ee2e5dd80e90fa6b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Release files / kthread_sleep-0.11-py3-none-any.whl
| Download URL | kthread_sleep-0.11-py3-none-any.whl |
|---|---|
| Size | 4.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ccb8d39b4053044b168012b20fd43bda69c366e5b6d030de7e4f62beb790d355
|
|
BLAKE2b-256 checksum How to use checksums |
83c3c9440c509e5959ce63934cabd2cb80d5671c2fb5e5f189d076ba23f4f022
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Security for kthread-sleep 0.11
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.