@@ -394,12 +394,13 @@ def __init__(self, arg: Flow | _engine.FlowLiveUpdater, options: FlowLiveUpdater
394
394
arg .internal_flow (), dump_engine_object (options or FlowLiveUpdaterOptions ())))
395
395
396
396
@staticmethod
397
- async def create (fl : Flow , options : FlowLiveUpdaterOptions | None = None ) -> FlowLiveUpdater :
397
+ async def create_async (fl : Flow , options : FlowLiveUpdaterOptions | None = None ) -> FlowLiveUpdater :
398
398
"""
399
399
Create a live updater for a flow.
400
+ Similar to the constructor, but for async usage.
400
401
"""
401
402
engine_live_updater = await _engine .FlowLiveUpdater .create (
402
- await fl .ainternal_flow (),
403
+ await fl .internal_flow_async (),
403
404
dump_engine_object (options or FlowLiveUpdaterOptions ()))
404
405
return FlowLiveUpdater (engine_live_updater )
405
406
@@ -408,21 +409,28 @@ def __enter__(self) -> FlowLiveUpdater:
408
409
409
410
def __exit__ (self , exc_type , exc_value , traceback ):
410
411
self .abort ()
411
- execution_context .run (self .wait ())
412
+ execution_context .run (self .wait_async ())
412
413
413
414
async def __aenter__ (self ) -> FlowLiveUpdater :
414
415
return self
415
416
416
417
async def __aexit__ (self , exc_type , exc_value , traceback ):
417
418
self .abort ()
418
- await self .wait ()
419
+ await self .wait_async ()
419
420
420
- async def wait (self ) -> None :
421
+ def wait (self ) -> None :
421
422
"""
422
423
Wait for the live updater to finish.
423
424
"""
425
+ execution_context .run (self .wait_async ())
426
+
427
+ async def wait_async (self ) -> None :
428
+ """
429
+ Wait for the live updater to finish. Async version.
430
+ """
424
431
await self ._engine_live_updater .wait ()
425
432
433
+
426
434
def abort (self ) -> None :
427
435
"""
428
436
Abort the live updater.
@@ -500,13 +508,20 @@ def name(self) -> str:
500
508
"""
501
509
return self ._lazy_engine_flow ().name ()
502
510
503
- async def update (self ) -> _engine .IndexUpdateInfo :
511
+ def update (self ) -> _engine .IndexUpdateInfo :
512
+ """
513
+ Update the index defined by the flow.
514
+ Once the function returns, the index is fresh up to the moment when the function is called.
515
+ """
516
+ return execution_context .run (self .update_async ())
517
+
518
+ async def update_async (self ) -> _engine .IndexUpdateInfo :
504
519
"""
505
520
Update the index defined by the flow.
506
- Once the function returns, the indice is fresh up to the moment when the function is called.
521
+ Once the function returns, the index is fresh up to the moment when the function is called.
507
522
"""
508
- updater = await FlowLiveUpdater .create (self , FlowLiveUpdaterOptions (live_mode = False ))
509
- await updater .wait ()
523
+ updater = await FlowLiveUpdater .create_async (self , FlowLiveUpdaterOptions (live_mode = False ))
524
+ await updater .wait_async ()
510
525
return updater .update_stats ()
511
526
512
527
def evaluate_and_dump (self , options : EvaluateAndDumpOptions ):
@@ -521,7 +536,7 @@ def internal_flow(self) -> _engine.Flow:
521
536
"""
522
537
return self ._lazy_engine_flow ()
523
538
524
- async def ainternal_flow (self ) -> _engine .Flow :
539
+ async def internal_flow_async (self ) -> _engine .Flow :
525
540
"""
526
541
Get the engine flow. The async version.
527
542
"""
@@ -587,21 +602,27 @@ def ensure_all_flows_built() -> None:
587
602
for fl in flows ():
588
603
fl .internal_flow ()
589
604
590
- async def aensure_all_flows_built () -> None :
605
+ async def ensure_all_flows_built_async () -> None :
591
606
"""
592
607
Ensure all flows are built.
593
608
"""
594
609
for fl in flows ():
595
- await fl .ainternal_flow ()
610
+ await fl .internal_flow_async ()
611
+
612
+ def update_all_flows (options : FlowLiveUpdaterOptions ) -> dict [str , _engine .IndexUpdateInfo ]:
613
+ """
614
+ Update all flows.
615
+ """
616
+ return execution_context .run (update_all_flows_async (options ))
596
617
597
- async def update_all_flows (options : FlowLiveUpdaterOptions ) -> dict [str , _engine .IndexUpdateInfo ]:
618
+ async def update_all_flows_async (options : FlowLiveUpdaterOptions ) -> dict [str , _engine .IndexUpdateInfo ]:
598
619
"""
599
620
Update all flows.
600
621
"""
601
- await aensure_all_flows_built ()
622
+ await ensure_all_flows_built_async ()
602
623
async def _update_flow (fl : Flow ) -> _engine .IndexUpdateInfo :
603
- updater = await FlowLiveUpdater .create (fl , options )
604
- await updater .wait ()
624
+ updater = await FlowLiveUpdater .create_async (fl , options )
625
+ await updater .wait_async ()
605
626
return updater .update_stats ()
606
627
fls = flows ()
607
628
all_stats = await asyncio .gather (* (_update_flow (fl ) for fl in fls ))
0 commit comments