Exemple #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)
Exemple #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()
Exemple #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()
Exemple #4
0
 async def test_acquire_nowait(self):
     condition = Condition()
     condition.acquire_nowait()
     assert condition.locked()