Skip to content

Commit 6d2c12f

Browse files
authored
feat(status-updates): add next_status_updates() for FlowLiveUpdater (#759)
1 parent 6318bf5 commit 6d2c12f

File tree

4 files changed

+343
-178
lines changed

4 files changed

+343
-178
lines changed

python/cocoindex/flow.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,18 @@ class FlowLiveUpdaterOptions:
534534
print_stats: bool = False
535535

536536

537+
class FlowUpdaterStatusUpdates(NamedTuple):
538+
"""
539+
Status updates for a flow updater.
540+
"""
541+
542+
# Sources that are still active, i.e. not stopped processing.
543+
active_sources: list[str]
544+
545+
# Sources with updates since last time.
546+
updated_sources: list[str]
547+
548+
537549
class FlowLiveUpdater:
538550
"""
539551
A live updater for a flow.
@@ -587,7 +599,23 @@ async def wait_async(self) -> None:
587599
"""
588600
Wait for the live updater to finish. Async version.
589601
"""
590-
await self._get_engine_live_updater().wait()
602+
await self._get_engine_live_updater().wait_async()
603+
604+
def next_status_updates(self) -> FlowUpdaterStatusUpdates:
605+
"""
606+
Get the next status updates.
607+
"""
608+
return execution_context.run(self.next_status_updates_async())
609+
610+
async def next_status_updates_async(self) -> FlowUpdaterStatusUpdates:
611+
"""
612+
Get the next status updates. Async version.
613+
"""
614+
updates = await self._get_engine_live_updater().next_status_updates_async()
615+
return FlowUpdaterStatusUpdates(
616+
active_sources=updates.active_sources,
617+
updated_sources=updates.updated_sources,
618+
)
591619

592620
def abort(self) -> None:
593621
"""

0 commit comments

Comments
 (0)