Beispiel #1
0
    async def test_acquire_nowait_wouldblock(self):
        async def try_lock():
            pytest.raises(WouldBlock, condition.acquire_nowait)

        condition = Condition()
        async with condition, create_task_group() as tg:
            assert condition.locked()
            tg.start_soon(try_lock)
Beispiel #2
0
    async def test_contextmanager(self):
        async def notifier():
            async with condition:
                condition.notify_all()

        condition = Condition()
        async with create_task_group() as tg:
            async with condition:
                assert condition.locked()
                tg.start_soon(notifier)
                await condition.wait()
Beispiel #3
0
    async def test_manual_acquire(self):
        async def notifier():
            await condition.acquire()
            try:
                condition.notify_all()
            finally:
                condition.release()

        condition = Condition()
        async with create_task_group() as tg:
            await condition.acquire()
            try:
                assert condition.locked()
                tg.start_soon(notifier)
                await condition.wait()
            finally:
                condition.release()
Beispiel #4
0
 async def test_acquire_nowait(self):
     condition = Condition()
     condition.acquire_nowait()
     assert condition.locked()