[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 07/31] python/aqmp: handle asyncio.TimeoutError on execute()
From: |
John Snow |
Subject: |
[PATCH v3 07/31] python/aqmp: handle asyncio.TimeoutError on execute() |
Date: |
Mon, 10 Jan 2022 18:28:46 -0500 |
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>
---
python/qemu/aqmp/qmp_client.py | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/python/qemu/aqmp/qmp_client.py b/python/qemu/aqmp/qmp_client.py
index 8105e29fa8..6a985ffe30 100644
--- a/python/qemu/aqmp/qmp_client.py
+++ b/python/qemu/aqmp/qmp_client.py
@@ -435,7 +435,11 @@ async def _issue(self, msg: Message) -> Union[None, str]:
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 @@ async def _reply(self, msg_id: Union[str, None]) -> Message:
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
--
2.31.1
- [PATCH v3 00/31] Python: delete synchronous qemu.qmp package, John Snow, 2022/01/10
- [PATCH v3 01/31] python/aqmp: use absolute import statement, John Snow, 2022/01/10
- [PATCH v3 02/31] Python/aqmp: fix type definitions for mypy 0.920, John Snow, 2022/01/10
- [PATCH v3 03/31] python: update type hints for mypy 0.930, John Snow, 2022/01/10
- [PATCH v3 04/31] simplebench: Fix Python syntax error (reported by LGTM), John Snow, 2022/01/10
- [PATCH v3 05/31] python/aqmp: fix docstring typo, John Snow, 2022/01/10
- [PATCH v3 07/31] python/aqmp: handle asyncio.TimeoutError on execute(),
John Snow <=
- [PATCH v3 06/31] python/aqmp: add __del__ method to legacy interface, John Snow, 2022/01/10
- [PATCH v3 09/31] python/aqmp: add SocketAddrT to package root, John Snow, 2022/01/10
- [PATCH v3 08/31] python/aqmp: copy type definitions from qmp, John Snow, 2022/01/10
- [PATCH v3 11/31] python/qemu-ga-client: don't use deprecated CLI syntax in usage comment, John Snow, 2022/01/10
- [PATCH v3 12/31] python/qmp: switch qemu-ga-client to AQMP, John Snow, 2022/01/10
- [PATCH v3 10/31] python/aqmp: rename AQMPError to QMPError, John Snow, 2022/01/10
- [PATCH v3 16/31] python: move qmp-shell under the AQMP package, John Snow, 2022/01/10