Skip to main content

Takes the hassle away from threading functions and gettting their results

Project description

Python Threadit

Running functions in threads with no effort

PyPI - Format PyPI - Status Downloads PyPI - Python Version

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


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)

Uploaded Source

Built Distribution

threadit-0.1.0-py3-none-any.whl (3.2 kB view hashes)

Uploaded Python 3

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