refactor: improve shutdown error messages

This commit is contained in:
tecnovert
2026-03-17 09:03:21 +02:00
committed by nahuhh
parent f668c38cd6
commit f577f84f09
2 changed files with 9 additions and 7 deletions

View File

@@ -1757,15 +1757,15 @@ def printHelp():
def finalise_daemon(d): def finalise_daemon(d):
logging.info("Interrupting {}".format(d.handle.pid)) logging.info(f"Interrupting {d.name} {d.handle.pid}")
try: try:
d.handle.send_signal(signal.CTRL_C_EVENT if os.name == "nt" else signal.SIGINT) d.handle.send_signal(signal.CTRL_C_EVENT if os.name == "nt" else signal.SIGINT)
d.handle.wait(timeout=120) d.handle.wait(timeout=120)
for fp in [d.handle.stdout, d.handle.stderr, d.handle.stdin] + d.files:
if fp:
fp.close()
except Exception as e: except Exception as e:
logging.info(f"Error {e} for process {d.handle.pid}") logging.info(f"Error stopping {d.name}, process {d.handle.pid}: {e}")
for fp in [d.handle.stdout, d.handle.stderr, d.handle.stdin] + d.files:
if fp:
fp.close()
def test_particl_encryption(data_dir, settings, chain, use_tor_proxy, extra_opts): def test_particl_encryption(data_dir, settings, chain, use_tor_proxy, extra_opts):

View File

@@ -618,7 +618,7 @@ def runClient(
signal.CTRL_C_EVENT if os.name == "nt" else signal.SIGINT signal.CTRL_C_EVENT if os.name == "nt" else signal.SIGINT
) )
except Exception as e: except Exception as e:
swap_client.log.info(f"Interrupting {d.name} {d.handle.pid}, error {e}") swap_client.log.error(f"Interrupting {d.name} {d.handle.pid}: {e}")
for d in daemons: for d in daemons:
try: try:
d.handle.wait(timeout=120) d.handle.wait(timeout=120)
@@ -627,7 +627,9 @@ def runClient(
fp.close() fp.close()
closed_pids.append(d.handle.pid) closed_pids.append(d.handle.pid)
except Exception as e: except Exception as e:
swap_client.log.error(f"Error: {e}") swap_client.log.error(
f"Waiting for {d.name} {d.handle.pid} to shutdown: {e}"
)
fail_code: int = swap_client.fail_code fail_code: int = swap_client.fail_code
del swap_client del swap_client