• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

修订版3b5bf136f5798a4ea2c66875d6337ca3d6b79434 (tree)
时间2022-01-22 06:01:31
作者John Snow <jsnow@redh...>
CommiterJohn Snow

Log Message

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>

更改概述

差异

--- a/python/qemu/aqmp/qmp_client.py
+++ b/python/qemu/aqmp/qmp_client.py
@@ -435,7 +435,11 @@ class QMPClient(AsyncProtocol[Message], Events):
435435 msg_id = msg['id']
436436
437437 self._pending[msg_id] = asyncio.Queue(maxsize=1)
438- await self._outgoing.put(msg)
438+ try:
439+ await self._outgoing.put(msg)
440+ except:
441+ del self._pending[msg_id]
442+ raise
439443
440444 return msg_id
441445
@@ -452,9 +456,9 @@ class QMPClient(AsyncProtocol[Message], Events):
452456 was lost, or some other problem.
453457 """
454458 queue = self._pending[msg_id]
455- result = await queue.get()
456459
457460 try:
461+ result = await queue.get()
458462 if isinstance(result, ExecInterruptedError):
459463 raise result
460464 return result