Skip to content

Commit ce0a7b3

Browse files
authored
Make FlowUpdater provide async context manager. (#257)
1 parent efdbc34 commit ce0a7b3

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

python/cocoindex/flow.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,13 @@ def __exit__(self, exc_type, exc_value, traceback):
390390
self.abort()
391391
asyncio.run(self.wait())
392392

393+
async def __aenter__(self) -> FlowLiveUpdater:
394+
return self
395+
396+
async def __aexit__(self, exc_type, exc_value, traceback):
397+
self.abort()
398+
await self.wait()
399+
393400
async def wait(self) -> None:
394401
"""
395402
Wait for the live updater to finish.
@@ -448,7 +455,7 @@ def name(self) -> str:
448455
"""
449456
return self._lazy_engine_flow().name()
450457

451-
async def update(self):
458+
async def update(self) -> _engine.IndexUpdateInfo:
452459
"""
453460
Update the index defined by the flow.
454461
Once the function returns, the indice is fresh up to the moment when the function is called.

0 commit comments

Comments
 (0)