Skip to content

Commit c9b3045

Browse files
jnsnowphilmd
authored andcommitted
python/machine.py: Add a configurable timeout to shutdown()
Three seconds is hardcoded. Use it as a default parameter instead, and use that value for both waits that may occur in the function. Signed-off-by: John Snow <[email protected]> Reviewed-by: Philippe Mathieu-Daudé <[email protected]> Reviewed-by: Cleber Rosa <[email protected]> Message-Id: <[email protected]> Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
1 parent a3842cb commit c9b3045

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

python/qemu/machine.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,9 @@ def wait(self):
393393
self._popen.wait()
394394
self._post_shutdown()
395395

396-
def shutdown(self, has_quit=False, hard=False):
396+
def shutdown(self, has_quit: bool = False,
397+
hard: bool = False,
398+
timeout: Optional[int] = 3) -> None:
397399
"""
398400
Terminate the VM and clean up
399401
"""
@@ -409,10 +411,10 @@ def shutdown(self, has_quit=False, hard=False):
409411
try:
410412
if not has_quit:
411413
self._qmp.cmd('quit')
412-
self._popen.wait(timeout=3)
414+
self._popen.wait(timeout=timeout)
413415
except:
414416
self._popen.kill()
415-
self._popen.wait()
417+
self._popen.wait(timeout=timeout)
416418

417419
self._post_shutdown()
418420

0 commit comments

Comments
 (0)