OSDN Git Service

Python: close the log file kept by QEMUMachine before reading it
authorCleber Rosa <crosa@redhat.com>
Thu, 11 Feb 2021 22:01:41 +0000 (17:01 -0500)
committerCleber Rosa <crosa@redhat.com>
Tue, 16 Feb 2021 02:40:16 +0000 (21:40 -0500)
Closing a file that is open for writing, and then reading from it
sounds like a better idea than the opposite, given that the content
will be flushed.

Reference: https://docs.python.org/3/library/io.html#io.IOBase.close
Signed-off-by: Cleber Rosa <crosa@redhat.com>
Message-Id: <20210211220146.2525771-2-crosa@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Signed-off-by: Cleber Rosa <crosa@redhat.com>
python/qemu/machine.py

index 7a40f46..6e44bda 100644 (file)
@@ -337,12 +337,12 @@ class QEMUMachine:
             self._qmp.close()
             self._qmp_connection = None
 
-        self._load_io_log()
-
         if self._qemu_log_file is not None:
             self._qemu_log_file.close()
             self._qemu_log_file = None
 
+        self._load_io_log()
+
         self._qemu_log_path = None
 
         if self._temp_dir is not None: