Takes the hassle away from threading functions and gettting their results
Project description
Python Threadit
Running functions in threads with no effort
A nice package to help you run functions in threads and get their result.
Installation
pip install threadit
Usage
from threadit import Threadit, thredit_result
@thredit_result
def get_company_name():
# Do work in thread
return 'Adapted'
def do_some_work():
get_name = Threadit(get_company_name)
# do stuff or run a while loop to wait for result
while get_name.doing_working():
print('Waiting for thread to finnish')
# You can also call .get() and the system will wait for the thread to return your result.
company_name = get_name.get()
print(company_name) # Outputs -> Adapted
Remember to add the @thredit_result decorator to the function you want to run in a thread, else you get back a SyntaxWarning.
Testing
Use the following command to run tests.
python -m unittest threadit.tests.test_threadit
Changelog:
See CHANGELOG.md
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
threadit-0.1.0.tar.gz
(2.3 kB
view hashes)