From: John Snow <jsnow@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
Eduardo Habkost <ehabkost@redhat.com>,
Wainer dos Santos Moschetta <wainersm@redhat.com>,
Cleber Rosa <crosa@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>, John Snow <jsnow@redhat.com>
Subject: [PATCH 2/3] python/qemu/qmp.py: re-raise OSError when encountered
Date: Fri, 9 Oct 2020 13:51:22 -0400 [thread overview]
Message-ID: <20201009175123.249009-3-jsnow@redhat.com> (raw)
In-Reply-To: <20201009175123.249009-1-jsnow@redhat.com>
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>
---
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 d911999da1f..4969e5741cb 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
next prev parent reply other threads:[~2020-10-09 17:55 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-09 17:51 [PATCH 0/3] python/qemu: strictly typed mypy conversion, pt3 John Snow
2020-10-09 17:51 ` [PATCH 1/3] python: add mypy config John Snow
2020-10-13 9:15 ` Bin Meng
2020-10-13 17:00 ` John Snow
2020-10-09 17:51 ` John Snow [this message]
2020-10-09 19:34 ` [PATCH 2/3] python/qemu/qmp.py: re-raise OSError when encountered Philippe Mathieu-Daudé
2020-10-09 17:51 ` [PATCH 3/3] python/qemu/qmp.py: Fix settimeout operation John Snow
2020-10-09 19:35 ` Philippe Mathieu-Daudé
2020-10-09 17:52 ` [PATCH 0/3] python/qemu: strictly typed mypy conversion, pt3 John Snow
2020-10-12 14:54 ` John Snow
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201009175123.249009-3-jsnow@redhat.com \
--to=jsnow@redhat.com \
--cc=crosa@redhat.com \
--cc=ehabkost@redhat.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=wainersm@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).