Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-1898

Close topology events executor faster after the topology is garbage collected

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.9
    • Affects Version/s: None
    • Component/s: None
    • None

      Topology's events executor is not closed as soon as it could be when the topology is garbage collected: https://github.com/mongodb/mongo-python-driver/blob/3.8.0/pymongo/topology.py#L116-L131

      The weakref.ref is defined like this:

                  # We strongly reference the executor and it weakly references
                  # the queue via this closure. When the topology is freed, stop
                  # the executor soon.
                  weak = weakref.ref(self._events)
      

      It should pass the executor's close method:

                  weak = weakref.ref(self._events, executor.close)
      

      Without executor.close the Topology events executor will still be closed but it will wait until the executor actually attempts to run (1 second instead of 0.5 seconds).

            Assignee:
            shane.harvey@mongodb.com Shane Harvey
            Reporter:
            shane.harvey@mongodb.com Shane Harvey
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: