Commits
Click on a commit to change the comparison rangefix: properly drain workers in prefect_test_harness when used in async contexts
Fixes #19762
When prefect_test_harness is used in an async context, the drain_all() and
drain() methods return coroutines that were never awaited, causing
RuntimeWarning: coroutine 'wait' was never awaited.
This fix uses the underlying _drain() method which returns a
concurrent.futures.Future that can be waited on synchronously, regardless
of whether there's a running event loop. This avoids creating unawaited
coroutines in the first place.
Changes:
- Use _drain() instead of drain()/drain_all() in prefect_test_harness cleanup
- Wait synchronously on the futures with concurrent.futures.wait()
- Copy EventsWorker instances before iterating to avoid dictionary mutation error
- Add regression test that fails if unawaited coroutines are created
Co-Authored-By: Nate Nowack <nate@prefect.io>10 hours ago
by devin-ai-integration[bot]