예제 #1
0
    async def _apply_step(self, idx, delay):
        res = None
        try:
            self.call_log.append(('A', idx, time.time()))
            res = yield self.res_lock_ref.apply(idx)
            assert res == idx + 1

            self.call_log.append(('B', idx, time.time()))
            yield asyncio.sleep(delay)
            self.call_log.append(('C', idx, time.time()))
        finally:
            await self.res_lock_ref.release()
            raise mo.Return(res)
예제 #2
0
 async def test_yield_tuple(self, delay=0.1):
     tp = yield tuple(
         self._apply_step(idx, delay)
         for idx in range(4)) + (asyncio.sleep(delay), 'PlainString')
     raise mo.Return(tp)
예제 #3
0
 async def apply(self, val=None):
     yield self._sem.acquire()
     raise mo.Return(val + 1 if val is not None else None)