[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 20/21] python/qemu/qmp.py: re-raise OSError when encountered
From: |
John Snow |
Subject: |
[PULL 20/21] python/qemu/qmp.py: re-raise OSError when encountered |
Date: |
Tue, 20 Oct 2020 13:27:41 -0400 |
Nested if conditions don't change when the exception block fires; we
need to explicitly re-raise the error if we didn't intend to capture and
suppress it.
Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-id: 20201009175123.249009-3-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
---
python/qemu/qmp.py | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/python/qemu/qmp.py b/python/qemu/qmp.py
index d911999da1..4969e5741c 100644
--- a/python/qemu/qmp.py
+++ b/python/qemu/qmp.py
@@ -165,14 +165,15 @@ def __get_events(self, wait: Union[bool, float] = False)
-> None:
"""
# Check for new events regardless and pull them into the cache:
- self.__sock.setblocking(False)
try:
+ self.__sock.setblocking(False)
self.__json_read()
except OSError as err:
- if err.errno == errno.EAGAIN:
- # No data available
- pass
- self.__sock.setblocking(True)
+ # EAGAIN: No data available; not critical
+ if err.errno != errno.EAGAIN:
+ raise
+ finally:
+ self.__sock.setblocking(True)
# Wait for new events, if needed.
# if wait is 0.0, this means "no wait" and is also implicitly false.
--
2.26.2
- [PULL 08/21] python/machine.py: Add _qmp access shim, (continued)
- [PULL 08/21] python/machine.py: Add _qmp access shim, John Snow, 2020/10/20
- [PULL 06/21] python/machine.py: Handle None events in events_wait, John Snow, 2020/10/20
- [PULL 10/21] python/qemu: make 'args' style arguments immutable, John Snow, 2020/10/20
- [PULL 09/21] python/machine.py: fix _popen access, John Snow, 2020/10/20
- [PULL 11/21] iotests.py: Adjust HMP kwargs typing, John Snow, 2020/10/20
- [PULL 14/21] python/qemu/console_socket.py: fix typing of settimeout, John Snow, 2020/10/20
- [PULL 13/21] python/qemu/console_socket.py: Correct type of recv(), John Snow, 2020/10/20
- [PULL 15/21] python/qemu/console_socket.py: Clarify type of drain_thread, John Snow, 2020/10/20
- [PULL 19/21] python: add mypy config, John Snow, 2020/10/20
- [PULL 12/21] python/qemu: Add mypy type annotations, John Snow, 2020/10/20
- [PULL 20/21] python/qemu/qmp.py: re-raise OSError when encountered,
John Snow <=
- [PULL 21/21] python/qemu/qmp.py: Fix settimeout operation, John Snow, 2020/10/20
- [PULL 17/21] python/qemu/console_socket.py: avoid encoding to/from string, John Snow, 2020/10/20
- [PULL 16/21] python/qemu/console_socket.py: Add type hint annotations, John Snow, 2020/10/20
- [PULL 18/21] python/qemu/qmp.py: Preserve error context on re-raise, John Snow, 2020/10/20