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.

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.10.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: kthread_sleep-0.10.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.10.tar.gz
Algorithm Hash digest
SHA256 baac68fba8f446311ced3226ac9570ceb9249707fead7294cbfe9989f943654b
MD5 79ead227c1dc7661a51d5a574a33be78
BLAKE2b-256 6665c1f9bbf87afecc595d6dfe4d823ada2da58d12c69ee384e8d04050355be9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kthread_sleep-0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 db2b0db438b0d7d4a633834d3899053bf8e10cf6fcf522f8b7d32490498d1f1a
MD5 9837e6bfa7cb14fb2c28940c26439ed8
BLAKE2b-256 d192d8748115f110bfaa20c52bdca3ff00da4d371e231ff3e1db91238f04e578

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