Skip to content

PYTHON-4147: Silence noisy thread.start() RuntimeError at shutdown #1486

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Feb 5, 2024
Prev Previous commit
Next Next commit
set to 'intepreter shutdown'
  • Loading branch information
Jibola committed Jan 31, 2024
commit 4eb02121e12a421452edf885c0a00b538fe4aa75
4 changes: 1 addition & 3 deletions pymongo/periodic_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@

from pymongo.lock import _create_lock

_THREAD_START_ON_SHUTDOWN_ERR = "can't create new thread at interpreter shutdown"


class PeriodicExecutor:
def __init__(
Expand Down Expand Up @@ -99,7 +97,7 @@ def open(self) -> None:
try:
thread.start()
except RuntimeError as e:
if _THREAD_START_ON_SHUTDOWN_ERR in str(e) or sys.is_finalizing():
if "interpreter shutdown" in str(e) or sys.is_finalizing():
self._thread = None
return
raise
Expand Down