Skip to main content

Busy wait easy-peasy

Project description

BusyPie

GitHub Actions Release License

Although you wouldn't want to do much busy waiting in your production code, Testing is a different matter. When testing asynchronous systems, it's very helpful to wait for somescenario to finish its course. BusyPie will help you to do busy waiting easily and expressively.

Installation

To install it using pip

python -m pip install busypie

To include it in requirements.txt file add

busypie==0.1

Example

Most typical usage will be in test, when we have a scenario that require us to wait for something to happen.

def test_event_should_be_dispatched():
    dispatcher.dispatch(event)
    wait().at_most(2, SECONDS).until(event_dispatched)

Usage

Wait for a condition. Default wait time is 10 seconds.

wait().until(condiction_function)

Specify maximum time to meet the condition

wait().at_most(FIVE_SECONDS).until(condition_function)
wait_at_most(FIVE_SECONDS).until(condition_function)
wait().at_most(10, SECOND).until(condition_function)
wait_at_most(10, SECONDS).until(condition_function)    

Ignoring exceptions thrown from condition function

wait().ignore_exceptions().until(condiction_function)

Credits

This project took a lot of inspiration from Awaitility

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

busypie-0.1.1.tar.gz (3.1 kB view hashes)

Uploaded source

Built Distribution

busypie-0.1.1-py3-none-any.whl (7.7 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page