@@ -394,15 +394,15 @@ def _hard_shutdown(self) -> None:
394
394
self ._popen .kill ()
395
395
self ._popen .wait (timeout = 60 )
396
396
397
- def _soft_shutdown (self , has_quit : bool = False ,
398
- timeout : Optional [ int ] = 3 ) -> None :
397
+ def _soft_shutdown (self , timeout : Optional [ int ] ,
398
+ has_quit : bool = False ) -> None :
399
399
"""
400
400
Perform early cleanup, attempt to gracefully shut down the VM, and wait
401
401
for it to terminate.
402
402
403
+ :param timeout: Timeout in seconds for graceful shutdown.
404
+ A value of None is an infinite wait.
403
405
:param has_quit: When True, don't attempt to issue 'quit' QMP command
404
- :param timeout: Optional timeout in seconds for graceful shutdown.
405
- Default 3 seconds, A value of None is an infinite wait.
406
406
407
407
:raise ConnectionReset: On QMP communication errors
408
408
:raise subprocess.TimeoutExpired: When timeout is exceeded waiting for
@@ -418,30 +418,30 @@ def _soft_shutdown(self, has_quit: bool = False,
418
418
# May raise subprocess.TimeoutExpired
419
419
self ._popen .wait (timeout = timeout )
420
420
421
- def _do_shutdown (self , has_quit : bool = False ,
422
- timeout : Optional [ int ] = 3 ) -> None :
421
+ def _do_shutdown (self , timeout : Optional [ int ] ,
422
+ has_quit : bool = False ) -> None :
423
423
"""
424
424
Attempt to shutdown the VM gracefully; fallback to a hard shutdown.
425
425
426
+ :param timeout: Timeout in seconds for graceful shutdown.
427
+ A value of None is an infinite wait.
426
428
:param has_quit: When True, don't attempt to issue 'quit' QMP command
427
- :param timeout: Optional timeout in seconds for graceful shutdown.
428
- Default 3 seconds, A value of None is an infinite wait.
429
429
430
430
:raise AbnormalShutdown: When the VM could not be shut down gracefully.
431
431
The inner exception will likely be ConnectionReset or
432
432
subprocess.TimeoutExpired. In rare cases, non-graceful termination
433
433
may result in its own exceptions, likely subprocess.TimeoutExpired.
434
434
"""
435
435
try :
436
- self ._soft_shutdown (has_quit , timeout )
436
+ self ._soft_shutdown (timeout , has_quit )
437
437
except Exception as exc :
438
438
self ._hard_shutdown ()
439
439
raise AbnormalShutdown ("Could not perform graceful shutdown" ) \
440
440
from exc
441
441
442
442
def shutdown (self , has_quit : bool = False ,
443
443
hard : bool = False ,
444
- timeout : Optional [int ] = 3 ) -> None :
444
+ timeout : Optional [int ] = 30 ) -> None :
445
445
"""
446
446
Terminate the VM (gracefully if possible) and perform cleanup.
447
447
Cleanup will always be performed.
@@ -453,7 +453,7 @@ def shutdown(self, has_quit: bool = False,
453
453
:param hard: When true, do not attempt graceful shutdown, and
454
454
suppress the SIGKILL warning log message.
455
455
:param timeout: Optional timeout in seconds for graceful shutdown.
456
- Default 3 seconds, A value of None is an infinite wait.
456
+ Default 30 seconds, A ` None` value is an infinite wait.
457
457
"""
458
458
if not self ._launched :
459
459
return
@@ -463,7 +463,7 @@ def shutdown(self, has_quit: bool = False,
463
463
self ._user_killed = True
464
464
self ._hard_shutdown ()
465
465
else :
466
- self ._do_shutdown (has_quit , timeout = timeout )
466
+ self ._do_shutdown (timeout , has_quit )
467
467
finally :
468
468
self ._post_shutdown ()
469
469
@@ -473,12 +473,12 @@ def kill(self):
473
473
"""
474
474
self .shutdown (hard = True )
475
475
476
- def wait (self , timeout : Optional [int ] = 3 ) -> None :
476
+ def wait (self , timeout : Optional [int ] = 30 ) -> None :
477
477
"""
478
478
Wait for the VM to power off and perform post-shutdown cleanup.
479
479
480
- :param timeout: Optional timeout in seconds.
481
- Default 3 seconds, A value of None is an infinite wait.
480
+ :param timeout: Optional timeout in seconds. Default 30 seconds.
481
+ A value of ` None` is an infinite wait.
482
482
"""
483
483
self .shutdown (has_quit = True , timeout = timeout )
484
484
0 commit comments