save-thread-result 0.1.1.post1
Simple subclass wrapper around `threading.Thread` to get the return value from a thread in python. Exact same interface as `threading.Thread`! 🌟 Star this repo if you found it useful! 🌟
pip install save-thread-result
Python API
Quickstart
Installing the save_thread_result module:
pip3 install -U save-thread-result # MacOS/Linux
pip install -U save-thread-result # Windows
# if that doesn't work:
python3 -m pip install -U save-thread-result # MacOS/Linux
python -m pip install -U save-thread-result # Windows
Using the ThreadWithResult class from the save_thread_result module:
from save_thread_result import ThreadWithResult
# As of Release 0.0.3, you can also specify values for
# `group`, `name`, and `daemon` if you want to set those
# values manually.
thread = ThreadWithResult(
target = my_function,
args = (my_function_arg1, my_function_arg2, ...)
kwargs = {my_function_kwarg1: kwarg1_value, my_function_kwarg2: kwarg2_value, ...}
)
thread.start()
thread.join()
if getattr(thread, 'result', None):
print(thread.result)
else:
# thread.result attribute not set - something caused
# the thread to terminate BEFORE the thread finished
# executing the function passed in through the
# `target` argument
print('ERROR! Something went wrong while executing this thread, and the function you passed in did NOT complete!!')
Reading the documentation for more information:
from save_thread_result import ThreadWithResult
help(ThreadWithResult)
Short explanation
This module uses a threading.Thread subclass ThreadWithResult that saves the result of a thread (from threading built-in module in the 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.
Examples
Dummy example:
from save_thread_result import ThreadWithResult
import time, random, threading
def function_to_thread(n):
count = 0
while count < 3:
print(f'Still running {threading.current_thread().name}...')
count +=1
time.sleep(3)
result = random.random()
print(f'Return value of {threading.current_thread().name} should be: {result}')
return result
def main():
thread1 = ThreadWithResult(target=function_to_thread, args=(1,))
thread2 = ThreadWithResult(target=function_to_thread, args=(2,))
thread1.start()
thread2.start()
thread1.join()
thread2.join()
print(f'The `result` attribute of {thread1.name} is: {thread1.result}')
print(f'The `result` attribute of {thread2.name} is: {thread2.result}')
main()
More information
Sources I looked at before creating the custom class
- Return value from thread
- Threading in python: retrieve return value when using target= [duplicate]
- How to get the return value from a thread in python?
- Using Python Threading and Returning Multiple Results (Tutorial)
- How to get the return value from a thread using python
- How to manage python threads results?
- How to obtain the results from a pool of threads in python?
- Google search
Project links
Key dates
PyPI data
- Released:
1 maintainer
PyPI data
Credits
Author: slow-but-steady
License
Free For Educational Use, Free For Home Use, Free for non-commercial use, Freely Distributable, Freeware, MIT License (MIT License)
Requires
Python >=3, <4
Tags
threading
thread
multi-threading
logging
logger
archiving
tracing
tracer
debugging
debugger
automation
csv
txt
markdown
md
YouTube
videos
URL
scraping
Selenium
macos
windows
linux
Classifiers
- Development Status
-
Environment
- MacOS X
- No Input/Output (Daemon)
- OpenStack
- Other Environment
- Plugins
- Web Environment
- Web Environment :: Buffet
- Web Environment :: Mozilla
- Web Environment :: ToscaWidgets
- Win32 (MS Windows)
- X11 Applications
- X11 Applications :: GTK
- X11 Applications :: Gnome
- X11 Applications :: KDE
- X11 Applications :: Qt
- Framework
- Intended Audience
- License
- Natural Language
-
Operating System
- Android
- BeOS
- MacOS
- MacOS :: MacOS 9
- MacOS :: MacOS X
- Microsoft
- Microsoft :: MS-DOS
- Microsoft :: Windows
- Microsoft :: Windows :: Windows 3.1 or Earlier
- Microsoft :: Windows :: Windows 7
- Microsoft :: Windows :: Windows 8
- Microsoft :: Windows :: Windows 8.1
- Microsoft :: Windows :: Windows 10
- Microsoft :: Windows :: Windows 95/98/2000
- Microsoft :: Windows :: Windows CE
- Microsoft :: Windows :: Windows NT/2000
- Microsoft :: Windows :: Windows Server 2003
- Microsoft :: Windows :: Windows Server 2008
- Microsoft :: Windows :: Windows Vista
- Microsoft :: Windows :: Windows XP
- OS Independent
- OS/2
- Other OS
- PDA Systems
- POSIX
- POSIX :: AIX
- POSIX :: BSD
- POSIX :: BSD :: BSD/OS
- POSIX :: BSD :: FreeBSD
- POSIX :: BSD :: NetBSD
- POSIX :: BSD :: OpenBSD
- POSIX :: GNU Hurd
- POSIX :: HP-UX
- POSIX :: IRIX
- POSIX :: Linux
- POSIX :: Other
- POSIX :: SCO
- POSIX :: SunOS/Solaris
- PalmOS
- Unix
- iOS
- Programming Language
-
Topic
- Adaptive Technologies
- Communications
- Communications :: BBS
- Communications :: Chat
- Communications :: Chat :: ICQ
- Communications :: Chat :: Internet Relay Chat
- Communications :: Chat :: Unix Talk
- Communications :: Conferencing
- Communications :: Email
- Communications :: Email :: Address Book
- Communications :: Email :: Email Clients (MUA)
- Communications :: Email :: Filters
- Communications :: Email :: Mail Transport Agents
- Communications :: Email :: Mailing List Servers
- Communications :: Email :: Post-Office
- Communications :: Email :: Post-Office :: IMAP
- Communications :: Email :: Post-Office :: POP3
- Communications :: FIDO
- Communications :: Fax
- Communications :: File Sharing
- Communications :: Ham Radio
- Communications :: Internet Phone
- Communications :: Telephony
- Communications :: Usenet News
- Database
- Desktop Environment
- Documentation
- Education
- Education :: Testing
- Games/Entertainment
- Games/Entertainment :: Arcade
- Games/Entertainment :: Board Games
- Games/Entertainment :: First Person Shooters
- Games/Entertainment :: Fortune Cookies
- Games/Entertainment :: Multi-User Dungeons (MUD)
- Games/Entertainment :: Puzzle Games
- Games/Entertainment :: Real Time Strategy
- Games/Entertainment :: Role-Playing
- Games/Entertainment :: Side-Scrolling/Arcade Games
- Games/Entertainment :: Simulation
- Games/Entertainment :: Turn Based Strategy
- Home Automation
- Internet
- Internet :: File Transfer Protocol (FTP)
- Internet :: Finger
- Internet :: Log Analysis
- Internet :: Name Service (DNS)
- Internet :: Proxy Servers
- Internet :: WAP
- Internet :: WWW/HTTP
- Internet :: WWW/HTTP :: Browsers
- Internet :: WWW/HTTP :: Dynamic Content
- Internet :: WWW/HTTP :: Dynamic Content :: CGI Tools/Libraries
- Internet :: WWW/HTTP :: Dynamic Content :: Content Management System
- Internet :: WWW/HTTP :: Dynamic Content :: Message Boards
- Internet :: WWW/HTTP :: Dynamic Content :: News/Diary
- Internet :: WWW/HTTP :: Dynamic Content :: Page Counters
- Internet :: WWW/HTTP :: Dynamic Content :: Wiki
- Internet :: WWW/HTTP :: HTTP Servers
- Internet :: WWW/HTTP :: Indexing/Search
- Internet :: WWW/HTTP :: Session
- Internet :: WWW/HTTP :: Site Management
- Internet :: WWW/HTTP :: Site Management :: Link Checking
- Internet :: WWW/HTTP :: WSGI
- Internet :: WWW/HTTP :: WSGI :: Application
- Internet :: WWW/HTTP :: WSGI :: Middleware
- Internet :: WWW/HTTP :: WSGI :: Server
- Internet :: XMPP
- Internet :: Z39.50
- Multimedia
- Multimedia :: Graphics
- Multimedia :: Graphics :: 3D Modeling
- Multimedia :: Graphics :: 3D Rendering
- Multimedia :: Graphics :: Capture
- Multimedia :: Graphics :: Capture :: Digital Camera
- Multimedia :: Graphics :: Capture :: Scanners
- Multimedia :: Graphics :: Capture :: Screen Capture
- Multimedia :: Graphics :: Editors
- Multimedia :: Graphics :: Editors :: Raster-Based
- Multimedia :: Graphics :: Editors :: Vector-Based
- Multimedia :: Graphics :: Graphics Conversion
- Multimedia :: Graphics :: Presentation
- Multimedia :: Graphics :: Viewers
- Multimedia :: Sound/Audio
- Multimedia :: Sound/Audio :: Analysis
- Multimedia :: Sound/Audio :: CD Audio
- Multimedia :: Sound/Audio :: CD Audio :: CD Playing
- Multimedia :: Sound/Audio :: CD Audio :: CD Ripping
- Multimedia :: Sound/Audio :: CD Audio :: CD Writing
- Multimedia :: Sound/Audio :: Capture/Recording
- Multimedia :: Sound/Audio :: Conversion
- Multimedia :: Sound/Audio :: Editors
- Multimedia :: Sound/Audio :: MIDI
- Multimedia :: Sound/Audio :: Mixers
- Multimedia :: Sound/Audio :: Players
- Multimedia :: Sound/Audio :: Players :: MP3
- Multimedia :: Sound/Audio :: Sound Synthesis
- Multimedia :: Sound/Audio :: Speech
- Multimedia :: Video
- Multimedia :: Video :: Capture
- Multimedia :: Video :: Conversion
- Multimedia :: Video :: Display
- Multimedia :: Video :: Non-Linear Editor
- Office/Business
- Office/Business :: Financial
- Office/Business :: Financial :: Accounting
- Office/Business :: Financial :: Investment
- Office/Business :: Scheduling
- Scientific/Engineering
- Scientific/Engineering :: Artificial Intelligence
- Scientific/Engineering :: Artificial Life
- Scientific/Engineering :: Astronomy
- Scientific/Engineering :: Atmospheric Science
- Scientific/Engineering :: Bio-Informatics
- Scientific/Engineering :: Chemistry
- Scientific/Engineering :: Electronic Design Automation (EDA)
- Scientific/Engineering :: GIS
- Scientific/Engineering :: Human Machine Interfaces
- Scientific/Engineering :: Image Processing
- Scientific/Engineering :: Image Recognition
- Scientific/Engineering :: Information Analysis
- Scientific/Engineering :: Mathematics
- Scientific/Engineering :: Medical Science Apps.
- Scientific/Engineering :: Physics
- Scientific/Engineering :: Visualization
- Security
- Security :: Cryptography
- Software Development
- Software Development :: Bug Tracking
- Software Development :: Build Tools
- Software Development :: Debuggers
- Software Development :: Embedded Systems
- Software Development :: Libraries
- Software Development :: Libraries :: Python Modules
- Software Development :: Testing
- Software Development :: Testing :: Acceptance
- Software Development :: Testing :: BDD
- Software Development :: Testing :: Mocking
- Software Development :: Testing :: Traffic Generation
- Software Development :: Testing :: Unit
- Software Development :: Version Control :: Git
- System
- System :: Benchmark
- System :: Boot
- System :: Boot :: Init
- System :: Distributed Computing
- System :: Filesystems
- System :: Hardware
- System :: Logging
- System :: Monitoring
- System :: Networking
- System :: Networking :: Firewalls
- System :: Networking :: Monitoring
- System :: Networking :: Time Synchronization
- System :: Operating System
- System :: Power (UPS)
- System :: Recovery Tools
- System :: Shells
- System :: Software Distribution
- System :: System Shells
- System :: Systems Administration
- System :: Systems Administration :: Authentication/Directory
- Terminals
- Utilities
Metadata
Project links
Key dates
PyPI data
- Released:
1 maintainer
PyPI data
Credits
Author: slow-but-steady
License
Free For Educational Use, Free For Home Use, Free for non-commercial use, Freely Distributable, Freeware, MIT License (MIT License)
Requires
Python >=3, <4
Tags
threading
thread
multi-threading
logging
logger
archiving
tracing
tracer
debugging
debugger
automation
csv
txt
markdown
md
YouTube
videos
URL
scraping
Selenium
macos
windows
linux
Classifiers
- Development Status
-
Environment
- MacOS X
- No Input/Output (Daemon)
- OpenStack
- Other Environment
- Plugins
- Web Environment
- Web Environment :: Buffet
- Web Environment :: Mozilla
- Web Environment :: ToscaWidgets
- Win32 (MS Windows)
- X11 Applications
- X11 Applications :: GTK
- X11 Applications :: Gnome
- X11 Applications :: KDE
- X11 Applications :: Qt
- Framework
- Intended Audience
- License
- Natural Language
-
Operating System
- Android
- BeOS
- MacOS
- MacOS :: MacOS 9
- MacOS :: MacOS X
- Microsoft
- Microsoft :: MS-DOS
- Microsoft :: Windows
- Microsoft :: Windows :: Windows 3.1 or Earlier
- Microsoft :: Windows :: Windows 7
- Microsoft :: Windows :: Windows 8
- Microsoft :: Windows :: Windows 8.1
- Microsoft :: Windows :: Windows 10
- Microsoft :: Windows :: Windows 95/98/2000
- Microsoft :: Windows :: Windows CE
- Microsoft :: Windows :: Windows NT/2000
- Microsoft :: Windows :: Windows Server 2003
- Microsoft :: Windows :: Windows Server 2008
- Microsoft :: Windows :: Windows Vista
- Microsoft :: Windows :: Windows XP
- OS Independent
- OS/2
- Other OS
- PDA Systems
- POSIX
- POSIX :: AIX
- POSIX :: BSD
- POSIX :: BSD :: BSD/OS
- POSIX :: BSD :: FreeBSD
- POSIX :: BSD :: NetBSD
- POSIX :: BSD :: OpenBSD
- POSIX :: GNU Hurd
- POSIX :: HP-UX
- POSIX :: IRIX
- POSIX :: Linux
- POSIX :: Other
- POSIX :: SCO
- POSIX :: SunOS/Solaris
- PalmOS
- Unix
- iOS
- Programming Language
-
Topic
- Adaptive Technologies
- Communications
- Communications :: BBS
- Communications :: Chat
- Communications :: Chat :: ICQ
- Communications :: Chat :: Internet Relay Chat
- Communications :: Chat :: Unix Talk
- Communications :: Conferencing
- Communications :: Email
- Communications :: Email :: Address Book
- Communications :: Email :: Email Clients (MUA)
- Communications :: Email :: Filters
- Communications :: Email :: Mail Transport Agents
- Communications :: Email :: Mailing List Servers
- Communications :: Email :: Post-Office
- Communications :: Email :: Post-Office :: IMAP
- Communications :: Email :: Post-Office :: POP3
- Communications :: FIDO
- Communications :: Fax
- Communications :: File Sharing
- Communications :: Ham Radio
- Communications :: Internet Phone
- Communications :: Telephony
- Communications :: Usenet News
- Database
- Desktop Environment
- Documentation
- Education
- Education :: Testing
- Games/Entertainment
- Games/Entertainment :: Arcade
- Games/Entertainment :: Board Games
- Games/Entertainment :: First Person Shooters
- Games/Entertainment :: Fortune Cookies
- Games/Entertainment :: Multi-User Dungeons (MUD)
- Games/Entertainment :: Puzzle Games
- Games/Entertainment :: Real Time Strategy
- Games/Entertainment :: Role-Playing
- Games/Entertainment :: Side-Scrolling/Arcade Games
- Games/Entertainment :: Simulation
- Games/Entertainment :: Turn Based Strategy
- Home Automation
- Internet
- Internet :: File Transfer Protocol (FTP)
- Internet :: Finger
- Internet :: Log Analysis
- Internet :: Name Service (DNS)
- Internet :: Proxy Servers
- Internet :: WAP
- Internet :: WWW/HTTP
- Internet :: WWW/HTTP :: Browsers
- Internet :: WWW/HTTP :: Dynamic Content
- Internet :: WWW/HTTP :: Dynamic Content :: CGI Tools/Libraries
- Internet :: WWW/HTTP :: Dynamic Content :: Content Management System
- Internet :: WWW/HTTP :: Dynamic Content :: Message Boards
- Internet :: WWW/HTTP :: Dynamic Content :: News/Diary
- Internet :: WWW/HTTP :: Dynamic Content :: Page Counters
- Internet :: WWW/HTTP :: Dynamic Content :: Wiki
- Internet :: WWW/HTTP :: HTTP Servers
- Internet :: WWW/HTTP :: Indexing/Search
- Internet :: WWW/HTTP :: Session
- Internet :: WWW/HTTP :: Site Management
- Internet :: WWW/HTTP :: Site Management :: Link Checking
- Internet :: WWW/HTTP :: WSGI
- Internet :: WWW/HTTP :: WSGI :: Application
- Internet :: WWW/HTTP :: WSGI :: Middleware
- Internet :: WWW/HTTP :: WSGI :: Server
- Internet :: XMPP
- Internet :: Z39.50
- Multimedia
- Multimedia :: Graphics
- Multimedia :: Graphics :: 3D Modeling
- Multimedia :: Graphics :: 3D Rendering
- Multimedia :: Graphics :: Capture
- Multimedia :: Graphics :: Capture :: Digital Camera
- Multimedia :: Graphics :: Capture :: Scanners
- Multimedia :: Graphics :: Capture :: Screen Capture
- Multimedia :: Graphics :: Editors
- Multimedia :: Graphics :: Editors :: Raster-Based
- Multimedia :: Graphics :: Editors :: Vector-Based
- Multimedia :: Graphics :: Graphics Conversion
- Multimedia :: Graphics :: Presentation
- Multimedia :: Graphics :: Viewers
- Multimedia :: Sound/Audio
- Multimedia :: Sound/Audio :: Analysis
- Multimedia :: Sound/Audio :: CD Audio
- Multimedia :: Sound/Audio :: CD Audio :: CD Playing
- Multimedia :: Sound/Audio :: CD Audio :: CD Ripping
- Multimedia :: Sound/Audio :: CD Audio :: CD Writing
- Multimedia :: Sound/Audio :: Capture/Recording
- Multimedia :: Sound/Audio :: Conversion
- Multimedia :: Sound/Audio :: Editors
- Multimedia :: Sound/Audio :: MIDI
- Multimedia :: Sound/Audio :: Mixers
- Multimedia :: Sound/Audio :: Players
- Multimedia :: Sound/Audio :: Players :: MP3
- Multimedia :: Sound/Audio :: Sound Synthesis
- Multimedia :: Sound/Audio :: Speech
- Multimedia :: Video
- Multimedia :: Video :: Capture
- Multimedia :: Video :: Conversion
- Multimedia :: Video :: Display
- Multimedia :: Video :: Non-Linear Editor
- Office/Business
- Office/Business :: Financial
- Office/Business :: Financial :: Accounting
- Office/Business :: Financial :: Investment
- Office/Business :: Scheduling
- Scientific/Engineering
- Scientific/Engineering :: Artificial Intelligence
- Scientific/Engineering :: Artificial Life
- Scientific/Engineering :: Astronomy
- Scientific/Engineering :: Atmospheric Science
- Scientific/Engineering :: Bio-Informatics
- Scientific/Engineering :: Chemistry
- Scientific/Engineering :: Electronic Design Automation (EDA)
- Scientific/Engineering :: GIS
- Scientific/Engineering :: Human Machine Interfaces
- Scientific/Engineering :: Image Processing
- Scientific/Engineering :: Image Recognition
- Scientific/Engineering :: Information Analysis
- Scientific/Engineering :: Mathematics
- Scientific/Engineering :: Medical Science Apps.
- Scientific/Engineering :: Physics
- Scientific/Engineering :: Visualization
- Security
- Security :: Cryptography
- Software Development
- Software Development :: Bug Tracking
- Software Development :: Build Tools
- Software Development :: Debuggers
- Software Development :: Embedded Systems
- Software Development :: Libraries
- Software Development :: Libraries :: Python Modules
- Software Development :: Testing
- Software Development :: Testing :: Acceptance
- Software Development :: Testing :: BDD
- Software Development :: Testing :: Mocking
- Software Development :: Testing :: Traffic Generation
- Software Development :: Testing :: Unit
- Software Development :: Version Control :: Git
- System
- System :: Benchmark
- System :: Boot
- System :: Boot :: Init
- System :: Distributed Computing
- System :: Filesystems
- System :: Hardware
- System :: Logging
- System :: Monitoring
- System :: Networking
- System :: Networking :: Firewalls
- System :: Networking :: Monitoring
- System :: Networking :: Time Synchronization
- System :: Operating System
- System :: Power (UPS)
- System :: Recovery Tools
- System :: Shells
- System :: Software Distribution
- System :: System Shells
- System :: Systems Administration
- System :: Systems Administration :: Authentication/Directory
- Terminals
- Utilities
Release files for save-thread-result 0.1.1.post1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| save-thread-result-0.1.1.post1.tar.gz | 16.7 kB | Without provenance | Details for save-thread-result-0.1.1.post1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| save_thread_result-0.1.1.post1-py3-none-any.whl 10.3 kB Without provenance | Python 3 | none | any | Details for save_thread_result-0.1.1.post1-py3-none-any.whl |
Total release size: 27.0 kB
Release files / save-thread-result-0.1.1.post1.tar.gz
| Download URL | save-thread-result-0.1.1.post1.tar.gz |
|---|---|
| Size | 16.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
46a214c1e204a8c4f92d293d0c121bb7bd38db98d79dc9b9384edce9dfbf0cbd
|
|
BLAKE2b-256 checksum How to use checksums |
6d45c05c254fb5e074f08a66882a9b0524509bf61a9c4d2b32409bf5ba13b84d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Release files / save_thread_result-0.1.1.post1-py3-none-any.whl
| Download URL | save_thread_result-0.1.1.post1-py3-none-any.whl |
|---|---|
| Size | 10.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8f78b4eac2e49b0978c86d2a0d5465dda5ec2f47c94c202b323e57d74eca3a34
|
|
BLAKE2b-256 checksum How to use checksums |
af6dfbf21b350439dc05bb7c8ed8fccd35f9be7186c1621cf8a08a6f1e2626bb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Security for save-thread-result 0.1.1.post1
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.