()
| 372 | state = 0 |
| 373 | |
| 374 | async def consumer(): |
| 375 | nonlocal state |
| 376 | async with condition: |
| 377 | while True: |
| 378 | await condition.wait_for(lambda: state != 0) |
| 379 | if state < 0: |
| 380 | return |
| 381 | state -= 1 |
| 382 | |
| 383 | # create two consumers |
| 384 | c = [asyncio.create_task(consumer()) for _ in range(2)] |