'This must be called while self.lock is held.'

def get_request_id(self):

    try:
        return self.request_ids.popleft()
    except IndexError:
        new_request_id = (self.highest_request_id + 1)
        assert (new_request_id <= self.max_request_id)
        self.highest_request_id = new_request_id
        return self.highest_request_id
