Function
watch_event
(session, data_type: type[T], predicate=None)
Source from the content-addressed store, hash-verified
| 17 | |
| 18 | |
| 19 | def watch_event(session, data_type: type[T], predicate=None) -> asyncio.Future: |
| 20 | loop = asyncio.get_running_loop() |
| 21 | future = loop.create_future() |
| 22 | |
| 23 | def on_event(event): |
| 24 | if isinstance(event.data, data_type) and (predicate is None or predicate(event.data)): |
| 25 | unsubscribe() |
| 26 | future.set_result(event) |
| 27 | |
| 28 | unsubscribe = session.on(on_event) |
| 29 | return future |
| 30 | |
| 31 | |
| 32 | async def wait_for_event(future: asyncio.Future) -> SessionEvent: |
Tested by
no test coverage detected
Used in the wild real call sites across dependent graphs
searching dependent graphs…