From 7724a18c4344bebba04a77f11eb770db46f0b322 Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Thu, 13 Aug 2026 19:30:06 +0200 Subject: [PATCH] Do not let a missing pid file break the exit callback The exit callback opened the pid file unguarded, so when it was already gone the atexit handler raised FileNotFoundError and python reported an exception ignored in an atexit callback. The removal of the debug socket immediately above is guarded, so this was an oversight rather than an intent. Verified by stopping the service with the pid file deleted first. --- confluent_server/confluent/main.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/confluent_server/confluent/main.py b/confluent_server/confluent/main.py index 0820a6a0..10648cdb 100644 --- a/confluent_server/confluent/main.py +++ b/confluent_server/confluent/main.py @@ -230,10 +230,15 @@ def doexit(): os.remove('/var/run/confluent/dbg.sock') except OSError: pass - pidfile = open('/var/run/confluent/pid') - pid = pidfile.read() - if pid == str(os.getpid()): - os.remove('/var/run/confluent/pid') + try: + with open('/var/run/confluent/pid') as pidfile: + pid = pidfile.read() + if pid == str(os.getpid()): + os.remove('/var/run/confluent/pid') + except OSError: + # Someone else already tidied it up, which is not worth a traceback out + # of an atexit callback + pass def _initsecurity(config):