RemoteWorker.cancel makes no coroutine once the loop is closed
run_coroutine_threadsafe refused it and it was never awaited, a RuntimeWarning under pytest 9. The cancel still logs that it could not reach the worker.
This commit is contained in:
@@ -249,6 +249,11 @@ class RemoteWorker:
|
||||
|
||||
def cancel(self, call_id: str) -> None:
|
||||
"""Ask the worker to kill what it is running for this call."""
|
||||
# A closed loop refuses the coroutine and leaves it never awaited, so it
|
||||
# is not made at all.
|
||||
if self._loop.is_closed():
|
||||
logger.warning("Could not cancel '%s' on '%s'", call_id, self.name)
|
||||
return
|
||||
try:
|
||||
asyncio.run_coroutine_threadsafe(
|
||||
self._send({"op": "cancel", "call_id": call_id}), self._loop
|
||||
|
||||
Reference in New Issue
Block a user