Skip to main content

A utility to manage and kill threads in Python applications

Project description

PyThreadKiller

A utility to manage and kill threads in Python applications.


GitHub Repo GitHub License GitHub Forks GitHub Stars GitHub Contributors

Build Status codecov PyPI Version Test PyPI Version

GitHub Image


Overview

PyThreadKiller is a utility designed to manage and kill threads in Python applications. This package provides a simple and effective way to terminate threads safely and retrieve return values from target functions.

Directory Structure

PyThreadKiller/
    ├── PyThreadKiller/
    │   ├── __init__.py
    │   ├── main.py
    ├── tests/
    │   ├── TestPyThreadKiller.py
    │   ├── UnittestPyThreadKiller.py
    ├── CHANGELOG.md
    ├── README.md
    ├── requirements.txt
    ├── .github/
    │   └── workflows/
    │       └── python-app.yml
    └── setup.py

Installation

You can install the package using pip:

pip install PyThreadKiller

Usage

  • Here is an example of how to use PyThreadKiller:
import time
from PyThreadKiller import PyThreadKiller

def example_target():
    for i in range(5):
        print(f"Thread is running... {i}")
        time.sleep(1)
    return True

# Create an instance of PyThreadKiller
thread = PyThreadKiller(target=example_target)
thread.start()

# Allow the thread to run for 3 seconds
time.sleep(3)

# Kill the thread
result = thread.kill()
print(f"Return value after killing the thread: {result}")

# Output:
# Thread is running... 0
# Thread is running... 1
# Thread is running... 2
# Thread killed successfully
# Return value after killing the thread: None

This file: tests/UnittestPyThreadKiller.py is integral to our CI/CD pipeline for automated testing.

License:

  • This project is licensed under the MIT License - see the LICENSE file for details.

  • This updated README.md includes the new project name, badges, a brief overview, the directory structure, installation instructions, usage example, changelog, and the main code for the PyThreadKiller class. Make sure to adjust any URLs and links to point to the correct resources for your project.

Changelog

[0.1] - 2024-05-19

Added

  • Initial draft of PyThreadKiller with basic thread management and killing functionality.

[3.0.4] - 2024-07-20

Fix

  • Test file for PyThreadKiller to test the package itself.

[3.0.6] - 2024-08-04

Documentation and CI/CD

  • Documentation update and CI/CD pipeline for automated testing

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

PyThreadKiller-3.0.6.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

PyThreadKiller-3.0.6-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file PyThreadKiller-3.0.6.tar.gz.

File metadata

  • Download URL: PyThreadKiller-3.0.6.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for PyThreadKiller-3.0.6.tar.gz
Algorithm Hash digest
SHA256 13a6bf4a23992afaf9b6036597df9e0ca2ba2ae37abec42321f11542449c1815
MD5 50b2c984d6361d573bbdf19906270bd2
BLAKE2b-256 4227bab5f84e9e0018f026364c28726dd0824529f595fec3e05c8fe2ac915e2f

See more details on using hashes here.

File details

Details for the file PyThreadKiller-3.0.6-py3-none-any.whl.

File metadata

File hashes

Hashes for PyThreadKiller-3.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 9b7d19c3d5915707d4cd8e7e2b83937cca4985e7efc9fd93a11ddfcbace9814a
MD5 4c74e36602ac1c24597839e09ae8abb4
BLAKE2b-256 94330500630163070a7c597713049f84896e0b1d3dc99b372fa540322560daf6

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