mirror of
https://github.com/xemu-project/xemu.git
synced 2024-11-27 05:20:50 +00:00
python/aqmp: handle asyncio.TimeoutError on execute()
This exception can be injected into any await statement. If we are canceled via timeout, we want to clear the pending execution record on our way out. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Beraldo Leal <bleal@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
This commit is contained in:
parent
3bc72e3aed
commit
3b5bf136f5
@ -435,7 +435,11 @@ class QMPClient(AsyncProtocol[Message], Events):
|
||||
msg_id = msg['id']
|
||||
|
||||
self._pending[msg_id] = asyncio.Queue(maxsize=1)
|
||||
await self._outgoing.put(msg)
|
||||
try:
|
||||
await self._outgoing.put(msg)
|
||||
except:
|
||||
del self._pending[msg_id]
|
||||
raise
|
||||
|
||||
return msg_id
|
||||
|
||||
@ -452,9 +456,9 @@ class QMPClient(AsyncProtocol[Message], Events):
|
||||
was lost, or some other problem.
|
||||
"""
|
||||
queue = self._pending[msg_id]
|
||||
result = await queue.get()
|
||||
|
||||
try:
|
||||
result = await queue.get()
|
||||
if isinstance(result, ExecInterruptedError):
|
||||
raise result
|
||||
return result
|
||||
|
Loading…
Reference in New Issue
Block a user