Skip to main content

PyBetterThreads

Downloads PyPi License

PyBetterThreads is a Python library for adding more features to the threading module in Python.

PyBetterThreads makes it possible to return values from threads, and adds a finished signal so that the user can execute a function once the thread is finished. It is still in early development, and more features will be added soon.

Installation

You can install PyBetterThreads using pip:

pip install PyBetterThreads

Usage

Here is an example of how to use PyBetterThreads:

from PyBetterThreads import BetterThread
from time import sleep

def my_function():
    sleep(5)
    return "Hello, World!"

thread = BetterThread(target=my_function)
thread.start()
thread.connect(print)

The above code will print "Hello, World!" after 5 seconds, as once the thread is finished, the returned value will passed to the print function. The returned value of the thread will be stored in the value attribute of the thread.

You can also use the join method to wait for the thread to finish and get the returned value, instead of connecting a function to the thread:

from PyBetterThreads import BetterThread
from time import sleep

def my_function():
    sleep(5)
    return "Hello, World!"

thread = BetterThread(target=my_function)
thread.start()
thread.join()
print(f"The thread returned: {thread.value}")

The above code will print "Hello, World!" after 5 seconds, as once the thread is finished, the returned value will be stored in the value attribute of the thread.

Features

  • Return values from threads
  • Execute a function once the thread is finished
  • More features coming soon!

License

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

Star History

Star History Chart

Metadata

Release files for PyBetterThreads 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PyBetterThreads 0.0.3
File Size Uploaded Provenance
pybetterthreads-0.0.3.tar.gz 3.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for PyBetterThreads 0.0.3
File Interpreter ABI Platform
PyBetterThreads-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 7.3 kB

Release files / pybetterthreads-0.0.3.tar.gz

Download URL pybetterthreads-0.0.3.tar.gz
Size 3.5 kB
Tags Source
SHA-256 checksum
How to use checksums
4ad65cd1bd4b1a2ea7ad4760df73d52b0caa433c9236eb092e0be14bc31d7fd3
BLAKE2b-256 checksum
How to use checksums
5c2000d480fdd9bb9d341b03822c87f45b7c758db01b9f1790921f5bcb23ec18
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.1

Release files / PyBetterThreads-0.0.3-py3-none-any.whl

Download URL PyBetterThreads-0.0.3-py3-none-any.whl
Size 3.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
48bdb3c6c362cdf1f0493cfef4b62a4741fbc578f50266866f2ffffb412d51d8
BLAKE2b-256 checksum
How to use checksums
35e25311880c1b65e8f666c9207a24cc3a4e04711c52f6c1e79c294610c3b05a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.1

Security for PyBetterThreads 0.0.3

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page