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

Remove threading.Lock() from SocketChecker

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor - P4
    • Resolution: Fixed
    • None
    • 3.11
    • Internal
    • None

    Description

      We can remove the threading.Lock() added to SocketChecker in PYTHON-1189 by giving each a connection its own SocketChecker() instance. Creating a SocketChecker is cheap so there should be no reason to use a single instance per pool.

      Another small improvement we can make is to remove the Pool.lock acquisition when popping a socket. deque.popleft() is already thread-safe so there is no reason to hold the lock here

                          with self.lock:
                              sock_info = self.sockets.popleft()
      

      Edit: Upon further thought, let's not remove the lock when popping a socket. Doing so would require changes to other sections of the Pool class which assume that sockets does not change when holding the lock.

      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: