'Used to clear a pending response queue and request queue
during connection drops.'

def _notify_pending(self, state):

    if (state == KeeperState.AUTH_FAILED):
        exc = AuthFailedError()
    elif (state == KeeperState.EXPIRED_SESSION):
        exc = SessionExpiredError()
    else:
        exc = ConnectionLoss()
    while True:
        try:
            (request, async_object, xid) = self._pending.popleft()
            if async_object:
                async_object.set_exception(exc)
        except IndexError:
            break
    while True:
        try:
            (request, async_object) = self._queue.popleft()
            if async_object:
                async_object.set_exception(exc)
        except IndexError:
            break
