Fix shutdown handling failing when exit code is not ExitCodes instance (#6112)

This commit is contained in:
Jakub Kuczys 2023-05-03 02:25:35 +02:00 committed by GitHub
parent af307377ad
commit 8996aee7fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -525,7 +525,12 @@ def main():
# We also have to catch this one here. Basically any exception which normally # We also have to catch this one here. Basically any exception which normally
# Kills the python interpreter (Base Exceptions minus asyncio.cancelled) # Kills the python interpreter (Base Exceptions minus asyncio.cancelled)
# We need to do something with prior to having the loop close # We need to do something with prior to having the loop close
log.info("Shutting down with exit code: %s (%s)", exc.code.value, exc.code.name) exit_code = int(exc.code)
try:
exit_code_name = ExitCodes(exit_code).name
except ValueError:
exit_code_name = "UNKNOWN"
log.info("Shutting down with exit code: %s (%s)", exit_code, exit_code_name)
if red is not None: if red is not None:
loop.run_until_complete(shutdown_handler(red, None, exc.code)) loop.run_until_complete(shutdown_handler(red, None, exc.code))
except Exception as exc: # Non standard case. except Exception as exc: # Non standard case.