async def test_suspend_resume__initially_suspended(self): flow_control = FlowControlEvent(initially_suspended=True) queue = FlowControlQueue(flow_control=flow_control) asyncio.ensure_future(self._resume_soon(0.2, flow_control)) time_now = monotonic() await queue.put(1) assert await queue.get() == 1 assert monotonic() - time_now > 0.1
async def test_suspend_resume(self): flow_control = FlowControlEvent() queue = FlowControlQueue(flow_control=flow_control) flow_control.resume() await queue.put(1) flow_control.suspend() asyncio.ensure_future(self._resume_soon(0.2, flow_control)) time_now = monotonic() await queue.put(2) assert monotonic() - time_now > 0.1 assert await queue.get() == 1 assert await queue.get() == 2
async def test_suspend_resume__initially_resumed(self): flow_control = FlowControlEvent(initially_suspended=False) queue = FlowControlQueue(flow_control=flow_control) await queue.put(1) assert await queue.get() == 1