Whole file

trbs/pid

The author described this change as fix atexit registration is never done #24. It counts as a record because the check below fails on the code as it stood at 62e5f4a28 and passes on 4a313cea5, with nothing else changed between the two runs.

Projecttrbs/pid
Fix saved2019-07-04
Sharing licenceApache-2.0 · LICENSE
Change size+9 7

What the code was meant to do, written into the code itself as a save note

fix atexit registration is never done #24

The change

3434
3535
3636 class PidFile(object):
37- __slots__ = ("pid", "pidname", "piddir", "enforce_dotpid_postfix",
38- "register_term_signal_handler", "register_atexit", "filename",
39- "fh", "lock_pidfile", "chmod", "uid", "gid", "force_tmpdir",
40- "allow_samepid", "_logger", "_is_setup", "_already_removed")
37+ __slots__ = (
38+ "pid", "pidname", "piddir", "enforce_dotpid_postfix",
39+ "register_term_signal_handler", "register_atexit", "filename",
40+ "fh", "lock_pidfile", "chmod", "uid", "gid", "force_tmpdir",
41+ "allow_samepid", "_logger", "_is_setup", "_already_removed",
42+ )
4143
4244 def __init__(self, pidname=None, piddir=None, enforce_dotpid_postfix=True,
4345 register_term_signal_handler='auto', register_atexit=True,
7880 self.filename = self._make_filename()
7981 self._register_term_signal()
8082
83+ if self.register_atexit:
84+ atexit.register(self.close)
85+
8186 # setup should only be performed once
8287 self._is_setup = True
8388
187192 self.fh.flush()
188193 self.fh.seek(0)
189194 self._already_removed = False
190-
191- if self.register_atexit and not self._is_setup:
192- atexit.register(self.close)
193195
194196 def close(self, fh=None, cleanup=None):
195197 self.logger.debug("%r closing pidfile: %s", self, self.filename)

The check that tells the two apart

failpass·tests/test_pid.py::test_register_atexit_true

Check file tests/test_pid.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it62e5f4a289ede9e55887e5279ca50a5063034dcd
Broken version dated2019-03-05
Modulepid.__init__
Units changedPidFile
Fingerprint021bc100f68b3982
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in trbs/pid