dispatchrun / dispatch-py

Python package to develop applications with Dispatch.
https://pypi.org/project/dispatch-py/
Apache License 2.0
54 stars 3 forks source link

Clamp min_results if greater than outstanding calls #93

Closed chriso closed 7 months ago

chriso commented 7 months ago

This addresses an issue that might occur when overriding poll_min_results from https://github.com/stealthrocket/dispatch-sdk-python/pull/92. If the value is less than the number of outstanding calls, Dispatch will unconditionally wait until the deadline (poll_max_wait_seconds). If no deadline is provided, Dispatch will never resume the coroutine and it will eventually expire.

This is not an issue with the default (poll_min_results=1) since there will always be at least one outstanding call when the scheduler yields to Dispatch (at least, until we introduce support for timers/sleep).

This PR fixes the issue by clamping min_results if it's greater than the number of outstanding calls.