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

Close topology events executor faster after the topology is garbage collected

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 3.9
    • None
    • None

    Description

      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).

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: