Пример #1
0
 def clean(self, address):
     self._lock.acquire()
     try:
         host = self.hosts.get(address)
         if not host: return
         while host.pool:
             socket = host.pool.popleft()
             sock.close(socket)
     finally:
         self._lock.release()
Пример #2
0
 def put(self, address, socket):
     self._lock.acquire()
     try:
         host = self.hosts.get(address)
         if not host:
             host = _Host(address)
             
         if len(host.pool) > self.max_connections:
             sock.close(socket)
             return
         host.pool.append(socket) 
     finally:
         self._lock.release()