Split periodic_executor.py into separate sync and async modules

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Works as Designed
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Python Drivers
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • 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

            Assignee:
            Unassigned
            Reporter:
            Alex Clark
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: