aboutsummaryrefslogtreecommitdiff
path: root/python/qemu
diff options
context:
space:
mode:
authorJohn Snow <jsnow@redhat.com>2021-05-27 17:16:49 -0400
committerJohn Snow <jsnow@redhat.com>2021-06-01 16:21:21 -0400
commit63c33f3c286efe4c6474b53ae97915c9d1a6923a (patch)
tree757d832be80aac6051223b6244121e8b71608790 /python/qemu
parent8825fed82a1949ed74f103c2ff26c4d71d2e4845 (diff)
downloadqemu-63c33f3c286efe4c6474b53ae97915c9d1a6923a.zip
qemu-63c33f3c286efe4c6474b53ae97915c9d1a6923a.tar.gz
qemu-63c33f3c286efe4c6474b53ae97915c9d1a6923a.tar.bz2
python/machine: Disable pylint warning for open() in _pre_launch
Shift the open() call later so that the pylint pragma applies *only* to that one open() call. Add a note that suggests why this is safe: the resource is unconditionally cleaned up in _post_shutdown(). _post_shutdown is called after failed launches (see launch()), and unconditionally after every call to shutdown(), and therefore also on __exit__. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Wainer dos Santos Moschetta <wainersm@redhat.com> Reviewed-by: Cleber Rosa <crosa@redhat.com> Message-id: 20210527211715.394144-6-jsnow@redhat.com Message-id: 20210517184808.3562549-6-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
Diffstat (limited to 'python/qemu')
-rw-r--r--python/qemu/machine.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/python/qemu/machine.py b/python/qemu/machine.py
index 04e005f..c66bc6a 100644
--- a/python/qemu/machine.py
+++ b/python/qemu/machine.py
@@ -306,7 +306,6 @@ class QEMUMachine:
def _pre_launch(self) -> None:
self._qemu_log_path = os.path.join(self.temp_dir, self._name + ".log")
- self._qemu_log_file = open(self._qemu_log_path, 'wb')
if self._console_set:
self._remove_files.append(self._console_address)
@@ -321,6 +320,11 @@ class QEMUMachine:
nickname=self._name
)
+ # NOTE: Make sure any opened resources are *definitely* freed in
+ # _post_shutdown()!
+ # pylint: disable=consider-using-with
+ self._qemu_log_file = open(self._qemu_log_path, 'wb')
+
def _post_launch(self) -> None:
if self._qmp_connection:
self._qmp.accept()