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.
- is related to
-
PYTHON-2108 POC : Reduce Client Time To Recovery On Topology Changes
- Closed