Improved exception handling for shutdown procedures

This commit is contained in:
Ezri Brimhall 2025-09-04 09:44:27 -06:00
parent 2ed041695f
commit 425d101f07
Signed by: ezri
GPG Key ID: 058A78E5680C6F24

View File

@ -358,14 +358,17 @@ class GlobalProtectConnection(
if self._wait_task is not None: if self._wait_task is not None:
self._wait_task.cancel() self._wait_task.cancel()
self._disconnecting = True self._disconnecting = True
self._proc.terminate() try:
self._proc.terminate()
except:
# Process doesn't exist, we are in the state we want so... :shrug: this is fine
return
# If the process takes longer than 10 seconds to exit, kill it sith WIGKILL # If the process takes longer than 10 seconds to exit, kill it sith WIGKILL
try: try:
async with timeout(10): async with timeout(10):
await self._proc_wait_task await self._proc_wait_task
except TimeoutError: except TimeoutError:
self._proc.kill() self._proc.kill()
await self._proc_wait_task
async def temporary_disconnect(self): async def temporary_disconnect(self):
f"""{super().temporary_disconnect.__doc__}""" f"""{super().temporary_disconnect.__doc__}"""