(session, predicate, timeout: float = 30.0)
| 188 | |
| 189 | |
| 190 | def wait_for_event(session, predicate, timeout: float = 30.0): |
| 191 | loop = asyncio.get_running_loop() |
| 192 | future = loop.create_future() |
| 193 | |
| 194 | def on_event(event): |
| 195 | if not future.done() and predicate(event): |
| 196 | future.set_result(event) |
| 197 | |
| 198 | unsubscribe = session.on(on_event) |
| 199 | |
| 200 | async def wait(): |
| 201 | try: |
| 202 | return await asyncio.wait_for(future, timeout=timeout) |
| 203 | finally: |
| 204 | unsubscribe() |
| 205 | |
| 206 | return loop.create_task(wait()) |
| 207 | |
| 208 | |
| 209 | class TestMultiClientBroadcast: |
no test coverage detected
searching dependent graphs…