diff --git a/pymongo/periodic_executor.py b/pymongo/periodic_executor.py index 68add5ed47..9a653d6022 100644 --- a/pymongo/periodic_executor.py +++ b/pymongo/periodic_executor.py @@ -126,6 +126,9 @@ def _on_executor_deleted(ref): def _shutdown_executors(): + if _EXECUTORS is None: + return + # Copy the set. Stopping threads has the side effect of removing executors. executors = list(_EXECUTORS)