Skip to main content

Simple subclass wrapper around `threading.Thread` to get the return value from a thread in python (from `threading` built-in package in Python Standard library). Exact same interface for creating an instance of this threading sublcass as `threading.Thread`!

Project description

save-thread-result Python API

GitHub license GitHub stars GitHub forks
PyPI version
PyPI - Wheel PyPI - Format PyPI - Status
PyPI - Implementation PyPI - Python Version
codebeat badge

Installing the package

Enter the following in your command line:

# if something isn't working properly, try rerunning this
# the problem may have been fixed with a newer version

pip3 install -U save-thread-result     # MacOS/Linux
pip  install -U save-thread-result     # Windows
Initializing the ThreadWithResult class

This package uses a threading.Thread subclass ThreadWithResult that saves the result of a thread (from threading built-in package in Python Standard library) as its result attribute - i.e. after the thread finishes running, call thread.result to get the return value from the function that ran on that thread.

python3     # MacOS/Linux
python      # Windows
from save_thread_result import ThreadWithResult

thread = ThreadWithResult(target=my_function, args=(my_function_arg1, my_function_arg2, ...))

thread.start()
thread.join()
print(thread.result)
Seeing all available methods and attributes for `ThreadWithResult` class
python3     # MacOS/Linux
python      # Windows
from save_thread_result import ThreadWithResult

help(ThreadWithResult)
Usage Statistics

PyPI - Daily Downloads
PyPI - Weekly Downloads PePY Weekly Downloads
PyPI - Monthly Downloads PePY Monthly Downloads
PePY Total Downloads

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

save-thread-result-0.0.3.tar.gz (12.3 kB view hashes)

Uploaded Source

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