python/aqmp: Reduce severity of EOFError-caused loop terminations
authorJohn Snow <jsnow@redhat.com>
Thu, 23 Sep 2021 00:49:27 +0000 (20:49 -0400)
committerJohn Snow <jsnow@redhat.com>
Tue, 12 Oct 2021 16:22:11 +0000 (12:22 -0400)
When we encounter an EOFError, we don't know if it's an "error" in the
perspective of the user of the library yet. Therefore, we should not log
it as an error. Reduce the severity of this logging message to "INFO" to
indicate that it's something that we expect to occur during the normal
operation of the library.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 20210923004938.3999963-7-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
python/qemu/aqmp/protocol.py

index 32e78749c1148df78a615c97a8d6092313693a49..ae1df240260fe77c4a1e6e746d2e7c9a3aeb1084 100644 (file)
@@ -721,8 +721,11 @@ class AsyncProtocol(Generic[T]):
             self.logger.debug("Task.%s: cancelled.", name)
             return
         except BaseException as err:
-            self.logger.error("Task.%s: %s",
-                              name, exception_summary(err))
+            self.logger.log(
+                logging.INFO if isinstance(err, EOFError) else logging.ERROR,
+                "Task.%s: %s",
+                name, exception_summary(err)
+            )
             self.logger.debug("Task.%s: failure:\n%s\n",
                               name, pretty_traceback())
             self._schedule_disconnect()