(step: float = 0.5)
| 99 | |
| 100 | |
| 101 | async def poll(step: float = 0.5) -> AsyncGenerator[float, None]: |
| 102 | loop = asyncio.get_running_loop() |
| 103 | start = loop.time() |
| 104 | while True: |
| 105 | before = loop.time() |
| 106 | yield before - start |
| 107 | after = loop.time() |
| 108 | wait = max([0, step - after + before]) |
| 109 | await asyncio.sleep(wait) |
| 110 | |
| 111 | |
| 112 | DEFAULT_CURTAIL = 80 |