code: def _connect(self):
          
          future = concurrent.Future()
  
          # Attempt to get a cached connection from the connection pool
          try:
              connection = self._pool_manager.get(self.pid, self)
              self._connections[connection.fileno()] = connection
              future.set_result(connection)
  
              # Add the connection to the IOLoop
              self._ioloop.add_handler(connection.fileno(),
                                       self._on_io_events,
                                       ioloop.IOLoop.WRITE)
          except pool.NoIdleConnectionsError:
              self._create_connection(future)
  
          return future
docs: Connect to PostgreSQL, either by reusing a connection from the pool
          if possible, or by creating the new connection.
  
          :rtype: psycopg2.extensions.connection
          :raises: pool.NoIdleConnectionsError