Fix deadlock when stopping queued script (#68175)

This commit is contained in:
Erik Montnemery 2022-03-15 16:29:04 +01:00 committed by GitHub
parent cdd23abea7
commit 8ea31cea3a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 2 deletions

View file

@ -860,12 +860,13 @@ class _QueuedScriptRun(_ScriptRun):
{lock_task, stop_task}, return_when=asyncio.FIRST_COMPLETED
)
except asyncio.CancelledError:
lock_task.cancel()
self._finish()
raise
else:
self.lock_acquired = lock_task.done() and not lock_task.cancelled()
finally:
lock_task.cancel()
stop_task.cancel()
self.lock_acquired = lock_task.done() and not lock_task.cancelled()
# If we've been told to stop, then just finish up. Otherwise, we've acquired the
# lock so we can go ahead and start the run.