$npx skillfedfor your agent

kthread

Killable threads in Python!

SkipPyPI Software DevelopmentReleased Feb 202290.0K downloads / mopermissive licensePure Python

Decision gist · record as of 2026-08-14

pure-Python wheel — kthread-0.2.3-py3-none-any.whl
v0.2.3 · released 2022-02-19

No. The package is abandoned (last update 2022-02-19) and comes with explicit warnings that thread termination can cause instability. Modern Python code should use threading.Event, queue.Queue, or async/await for controlled thread shutdown. Install only if you have a specific legacy codebase already using it and cannot refactor to safer patterns.AI-flagged interpretation of the facts on this page — verify before relying

Before you install

  • Threads blocked on OS calls (sleep, socket operations) may not respond to termination.
  • The package uses CPython internals and may not work on non-CPython implementations.
  • Installation is straightforward with no runtime dependencies.

License · maintenance · safety

permissive license (permissive) — MIT license permits free use, modification, and distribution with minimal restrictions, making it legally safe to integrate into most projects.

last release 2022-02-19 (1637 days) · last repo commit 2022-02-19 · 16 stars

0 known vulnerabilities (OSV.dev, 2026-08-14) · 89,985 downloads/mo, #13,626 on PyPI

Verify before relying

import time
import kthread

def worker():
    while True:
        time.sleep(0.2)

t = kthread.KThread(target=worker)
t.start()
t.terminate()  # or t.kill() or t.exit()
  • Whether the CPython API approach works reliably across Python 3.x versions beyond what the classifiers claim
  • Specific Python versions where OS-blocked threads (sleep, accept, recv) cannot be interrupted
  • Compatibility with async/await patterns or modern concurrency libraries
Same gist for agents: .md · .json

What it is and what it does

KThread is a thin wrapper around Python's threading.Thread that adds methods to forcefully terminate a running thread by injecting a SystemExit exception via the CPython API. It solves the problem that the standard library offers no built-in way to stop a thread once started—you can only wait for it to finish naturally.

The package works by leveraging low-level CPython internals to raise an exception inside a target thread. Threads blocked on OS calls (like time.sleep, socket.accept, or socket.recv) will not respond to termination. The author includes a strong disclaimer that thread termination can introduce instability, resource leaks, or other undesirable effects, and provides no warranty. It is intended for cases where you have no other way to stop a thread and accept the risks.

Use it for

  • Stopping long-running worker threads when a parent process receives a shutdown signal
  • Cleaning up threads that enter infinite loops and cannot be interrupted by normal means
  • Testing code that spawns threads, where you need to forcibly halt them between test cases
  • Implementing timeout mechanisms for thread-based operations when standard timeout patterns are unavailable

Worth the install?

AI-flagged interpretation of the facts on this page. Verify before relying on it.

Skip

No.

The package is abandoned (last update 2022-02-19) and comes with explicit warnings that thread termination can cause instability. Modern Python code should use threading.Event, queue.Queue, or async/await for controlled thread shutdown. Install only if you have a specific legacy codebase already using it and cannot refactor to safer patterns.

Install

kthread on PyPI

Before you install

Installation is straightforward with no runtime dependencies. However, the package is abandoned—last release was 2022-02-19 with no updates since, and the repository shows minimal activity (16 stars). Use only if you accept the maintenance risk.

Threads blocked on OS calls (sleep, socket operations) may not respond to termination. The package uses CPython internals and may not work on non-CPython implementations.

License in practice

MIT license permits free use, modification, and distribution with minimal restrictions, making it legally safe to integrate into most projects.

Quickstart

import time
import kthread

def worker():
    while True:
        time.sleep(0.2)

t = kthread.KThread(target=worker)
t.start()
t.terminate()  # or t.kill() or t.exit()

Verify before relying

  • Whether the CPython API approach works reliably across Python 3.x versions beyond what the classifiers claim
  • Specific Python versions where OS-blocked threads (sleep, accept, recv) cannot be interrupted
  • Compatibility with async/await patterns or modern concurrency libraries

Package facts

Licensepermissive license permissive
Python supportNot specified
Install frictionLow. Pure-Python wheel
Runtime dependenciesNone
MaintenanceAbandoned 1,637 days since the last release
Last repo commit
First released
Downloads89,985 / month, #13,626 on PyPI 30-day window, as of 2026-08-14
Known vulnerabilitiesNone known OSV.dev, checked 2026-08-14
Classifiers
License :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 2.7Programming Language :: Python :: 3

Evidence: kthread-0.2.3-py3-none-any.whl

Tags

Capabilities
kill thread pythonterminate thread forcefullystop running threadthread terminationkillable threadsthread exitforce thread stop
Topics
threadinglegacy-maintenance-risk
PyPI keywords
threadingthreadsterminate

Let your AI agent find packages like this

Example. Real query, live index.

You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.

wish › “kill thread python”

  • kthreadKThread provides a way to forcefully terminate running threads by…
  • aa-killstatsA Django module for AllianceAuth that tracks and displays EVE Online…
  • django-pgactivityProvides Django management commands and utilities to view, filter,…

Give your agent the search over MCP, or paste the wish link into any chat.

More Software Development packages

typing-extensions Worth it
PyPI · Software Development · released Jul 2026

Provides backported and experimental type hints for Python 3.9+, allowing use of newer typing features on older Python versions and enabling early experimentation with type system PEPs before they enter the standard library.

PSF-2.0pure Python · 3.9+
1.9Bdownloads / mo
numpy Worth it
PyPI · Software Development · released Aug 2026

NumPy provides an N-dimensional array object and a comprehensive suite of mathematical, linear algebra, Fourier transform, and random number functions for scientific computing in Python.

BSD-3-Clause AND 0BSD AND MIT AND Zlib AND CC0-1.0compiled wheel · 3.12+
1.1Bdownloads / mo
fastapi Worth it
PyPI · Software Development · released Jul 2026

FastAPI is a Python web framework for building REST APIs using type hints, with automatic request validation, serialization, and interactive API documentation.

MITpure Python · 3.10+
568.6Mdownloads / mo
annotated-doc With conditions
PyPI · Software Development · released Jul 2026

Provides a way to document function parameters, class attributes, return types, and variables inline using Python's `Annotated` type hint syntax instead of traditional docstrings.

MITpure Python · 3.9+
456.2Mdownloads / mo
typer Worth it
PyPI · Software Development · released Aug 2026

Typer builds command-line applications from Python functions using type hints, automatically generating help text, argument parsing, and shell completion.

Install it if you are building CLIs in Python.

MITpure Python · 3.10+
369.3Mdownloads / mo
distlib With conditions
PyPI · Software Development · released Jun 2026

Distlib provides low-level packaging utilities for building, distributing, and managing Python software—including metadata handling, version specifiers, wheel support, script installation, and dependency resolution.

permissive licensepure Python
323.3Mdownloads / mo

See also func-timeout · threaded · stopit · pytest-reraise · Flask-Threads · simpervisor · lib-cli-exit-tools · pytest-threadleak · opentelemetry-instrumentation-threading · pytest-run-parallel