code: def _poll_connection(self, fd):
          
          try:
              state = self._connections[fd].poll()
          except (OSError, socket.error) as error:
              self._ioloop.remove_handler(fd)
              if fd in self._futures and not self._futures[fd].done():
                  self._futures[fd].set_exception(
                      psycopg2.OperationalError('Connection error (%s)' % error)
                  )
          except (psycopg2.Error, psycopg2.Warning) as error:
              if fd in self._futures and not self._futures[fd].done():
                  self._futures[fd].set_exception(error)
          else:
              if state == extensions.POLL_OK:
                  if fd in self._futures and not self._futures[fd].done():
                      self._futures[fd].set_result(True)
              elif state == extensions.POLL_WRITE:
                  self._ioloop.update_handler(fd, ioloop.IOLoop.WRITE)
              elif state == extensions.POLL_READ:
                  self._ioloop.update_handler(fd, ioloop.IOLoop.READ)
              elif state == extensions.POLL_ERROR:
                  self._ioloop.remove_handler(fd)
                  if fd in self._futures and not self._futures[fd].done():
                      self._futures[fd].set_exception(
                          psycopg2.Error('Poll Error'))
docs: Check with psycopg2 to see what action to take. If the state is
          POLL_OK, we should have a pending callback for that fd.
  
          :param int fd: The socket fd for the postgresql connection