async def _write_frame_awaiting_response(self, waiter_id, frame, request,
                                         no_wait, check_open=True, drain=True):
    '''Write a frame and set a waiter for
    the response (unless no_wait is set)'''
    if no_wait:
        await self._write_frame(frame, request, check_open=check_open,
                                     drain=drain)
        return None

    f = self._set_waiter(waiter_id)
    try:
        await self._write_frame(frame, request, check_open=check_open,
                                     drain=drain)
    except Exception:
        self._get_waiter(waiter_id)
        f.cancel()
        raise
    result = await f
    try:
        self._get_waiter(waiter_id)
    except aioamqp.SynchronizationError:
        # no waiter to get
        pass
    return result