Am 07.10.2020 um 01:58 hat John Snow geschrieben: > 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 <js...@redhat.com> > --- > python/qemu/qmp.py | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/python/qemu/qmp.py b/python/qemu/qmp.py > index d911999da1f..bdbd1e9bdbb 100644 > --- a/python/qemu/qmp.py > +++ b/python/qemu/qmp.py > @@ -169,9 +169,9 @@ def __get_events(self, wait: Union[bool, float] = False) > -> None: > try: > self.__json_read() > except OSError as err: > - if err.errno == errno.EAGAIN: > - # No data available > - pass > + # EAGAIN: No data available; not critical > + if err.errno != errno.EAGAIN: > + raise
Hm, if we re-raise the exception here, the socket remains non-blocking. I think we intended to have it like that only temporarily. The same kind of exception would raise QMPConnectError below instead of directly OSError. Should we try to make this consistent? > self.__sock.setblocking(True) > > # Wait for new events, if needed. Kevin