Skip to content

Commit

Permalink
Mitigate Python 3.12 shutdown RuntimeError
Browse files Browse the repository at this point in the history
Python 3.12 introduced a bug during the interpreter shutdown, see:
- issue python/cpython#104826
- bugfix python/cpython#117029

With Python 3.12.3, this change could potentially be reverted (after testing).
  • Loading branch information
ppigazzini committed Apr 4, 2024
1 parent c59a834 commit c8173d2
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions server/fishtest/rundb.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,16 @@ def get_run(self, r_id):
return None

def start_timer(self):
self.timer = threading.Timer(1.0, self.flush_buffers)
self.timer.start()
try:
self.timer = threading.Timer(1.0, self.flush_buffers)
self.timer.start()
except RuntimeError as e:
# Mitigation for a 3.12 bug during the interpreter shutdown, see:
# - issue https://github.com/python/cpython/pull/104826
# - bugfix https://github.com/python/cpython/pull/117029
# With python 3.12.3 the try except block could be potentially removed.
if "interpreter shutdown" not in str(e):
raise

def buffer(self, run, flush):
with self.run_cache_lock:
Expand Down

0 comments on commit c8173d2

Please sign in to comment.