Skip to main content

A killable sleep function for kthread

Project description

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

Project details


Download files

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

Source Distribution

kthread_sleep-0.11.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

kthread_sleep-0.11-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file kthread_sleep-0.11.tar.gz.

File metadata

  • Download URL: kthread_sleep-0.11.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for kthread_sleep-0.11.tar.gz
Algorithm Hash digest
SHA256 eff9e2e8d46d37548c1a47e1e5ea09974a027a757d0611df06256cd24c5c63a8
MD5 3555e7c43ee68c400dfaa1a256cc0773
BLAKE2b-256 7066afa7508bfef9229f7d1b863edd20144d2f9ea25a1952ee2e5dd80e90fa6b

See more details on using hashes here.

File details

Details for the file kthread_sleep-0.11-py3-none-any.whl.

File metadata

File hashes

Hashes for kthread_sleep-0.11-py3-none-any.whl
Algorithm Hash digest
SHA256 ccb8d39b4053044b168012b20fd43bda69c366e5b6d030de7e4f62beb790d355
MD5 6286ff0845c93106120c1eb180e19cb5
BLAKE2b-256 83c3c9440c509e5959ce63934cabd2cb80d5671c2fb5e5f189d076ba23f4f022

See more details on using hashes here.

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