-
Type:
Task
-
Resolution: Works as Designed
-
Priority:
Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Python Drivers
-
None
-
None
-
None
-
None
-
None
-
None
Summary
pymongo/periodic_executor.py is a top-level shared module containing both AsyncPeriodicExecutor and PeriodicExecutor in the same file, along with shared module-level state (_EXECUTORS, _register_executor, _on_executor_deleted, _shutdown_executors).
Similar to PYTHON-5806 (splitting network_layer.py), this ticket tracks factoring the sync and async executor classes into separate modules.
Current Structure
- AsyncPeriodicExecutor (lines 33–121) — asyncio-based, no threading
- PeriodicExecutor (lines 123–257) — threading-based
- Module-level functions (lines 268–295) — _EXECUTORS, _register_executor, _on_executor_deleted, _shutdown_executors — only used by PeriodicExecutor, but imported by both synchronous/monitor.py and asynchronous/monitor.py
Complications vs. PYTHON-5806
- periodic_executor.py is a top-level module (not under pymongo/synchronous/ or pymongo/asynchronous/), so splitting it would change import paths at all four call sites (synchronous/monitor.py, asynchronous/monitor.py, synchronous/mongo_client.py, asynchronous/mongo_client.py, synchronous/topology.py, asynchronous/topology.py)
- The module-level shared state (_EXECUTORS etc.) belongs logically to PeriodicExecutor only, but asynchronous/monitor.py also imports _shutdown_executors — needs a clear home
- The two classes are structurally different enough that synchro-style generation does not apply
Related
PYTHON-5806— Split network_layer.py into sync and async modules