Polling2: Never write another polling function¶
Release v0.5.0.
Polling2 is a powerful python utility used to wait for a function to return when the specified condition is met.
Install¶
polling2 is available from Pypi.:
python -m pip install polling2
Examples¶
Watch polling do some arbitrary dances:
>> import polling2, time
>> # Wait until the number of seconds (ignoring milliseconds) is divisible by 5.
>> polling2.poll(target=time.time, check_success=lambda x: int(x) % 5 == 0, step=0.5, timeout=6)
1599737060.4507122
>> # Lets use the decorator version to create a function that waits until the next even second.
>> @polling2.poll_decorator(check_success=lambda x: int(x) % 2 == 0, step=0.5, timeout=6)
... def even_time():
... return time.time()
>> even_time()
1599737080.016323
>> even_time()
1599737082.035758
View all the examples:
- Examples
- Poll under the current time in seconds is divisble by 5
- Poll every minute until a url returns 200 status code
- Poll but ignore specifc exceptions
- Poll for a file to exist
- Polling for Selenium WebDriver elements
- Using the polling timeout exception
- Use a custom checker to decide whether your target has returned what your waiting for
- Using a custom condition callback function
- Logging the return values from the target function
- Poll a target forever
- Wrap a target function in a polling decorator
API¶
Contributor Guide¶
If you want to contribute to the project…
Release notes¶
The change log for each released version.