[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 02/23] python/aqmp: handle asyncio.TimeoutError on execute()
From: |
John Snow |
Subject: |
[PATCH 02/23] python/aqmp: handle asyncio.TimeoutError on execute() |
Date: |
Wed, 24 Nov 2021 14:25:56 -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>
---
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 00/23] Python: delete qemu.qmp package, John Snow, 2021/11/24
- [PATCH 04/23] python/aqmp: add SocketAddrT to package root, John Snow, 2021/11/24
- [PATCH 05/23] python/qemu-ga-client: update instructions to newer CLI syntax, John Snow, 2021/11/24
- [PATCH 01/23] python/aqmp: add __del__ method to legacy interface, John Snow, 2021/11/24
- [PATCH 08/23] python/qmp: switch qmp-shell to AQMP, John Snow, 2021/11/24
- [PATCH 10/23] python: move qmp-shell under the AQMP package, John Snow, 2021/11/24
- [PATCH 13/23] scripts/cpu-x86-uarch-abi: switch to AQMP, John Snow, 2021/11/24
- [PATCH 02/23] python/aqmp: handle asyncio.TimeoutError on execute(),
John Snow <=
- [PATCH 03/23] python/aqmp: copy type definitions from qmp, John Snow, 2021/11/24
- [PATCH 06/23] python/qmp: switch qemu-ga-client to AQMP, John Snow, 2021/11/24
- [PATCH 07/23] python/qmp: switch qom tools to AQMP, John Snow, 2021/11/24
- [PATCH 09/23] python: move qmp utilities to python/qemu/utils, John Snow, 2021/11/24
- [PATCH 14/23] scripts/render-block-graph: switch to AQMP, John Snow, 2021/11/24
- [PATCH 11/23] python/machine: permanently switch to AQMP, John Snow, 2021/11/24
- [PATCH 12/23] scripts/cpu-x86-uarch-abi: fix CLI parsing, John Snow, 2021/11/24
- [PATCH 17/23] iotests: switch to AQMP, John Snow, 2021/11/24
- [PATCH 19/23] python/aqmp: take QMPBadPortError and parse_address from qemu.qmp, John Snow, 2021/11/24
- [PATCH 15/23] scripts/bench-block-job: switch to AQMP, John Snow, 2021/11/24