@@ -287,6 +287,7 @@ async def start_workflow(
287
287
start_signal_args : Sequence [Any ] = [],
288
288
rpc_metadata : Mapping [str , str ] = {},
289
289
rpc_timeout : Optional [timedelta ] = None ,
290
+ request_eager_start : bool = False ,
290
291
) -> WorkflowHandle [SelfType , ReturnType ]:
291
292
...
292
293
@@ -317,6 +318,7 @@ async def start_workflow(
317
318
start_signal_args : Sequence [Any ] = [],
318
319
rpc_metadata : Mapping [str , str ] = {},
319
320
rpc_timeout : Optional [timedelta ] = None ,
321
+ request_eager_start : bool = False ,
320
322
) -> WorkflowHandle [SelfType , ReturnType ]:
321
323
...
322
324
@@ -349,6 +351,7 @@ async def start_workflow(
349
351
start_signal_args : Sequence [Any ] = [],
350
352
rpc_metadata : Mapping [str , str ] = {},
351
353
rpc_timeout : Optional [timedelta ] = None ,
354
+ request_eager_start : bool = False ,
352
355
) -> WorkflowHandle [SelfType , ReturnType ]:
353
356
...
354
357
@@ -381,6 +384,7 @@ async def start_workflow(
381
384
start_signal_args : Sequence [Any ] = [],
382
385
rpc_metadata : Mapping [str , str ] = {},
383
386
rpc_timeout : Optional [timedelta ] = None ,
387
+ request_eager_start : bool = False ,
384
388
) -> WorkflowHandle [Any , Any ]:
385
389
...
386
390
@@ -411,6 +415,7 @@ async def start_workflow(
411
415
start_signal_args : Sequence [Any ] = [],
412
416
rpc_metadata : Mapping [str , str ] = {},
413
417
rpc_timeout : Optional [timedelta ] = None ,
418
+ request_eager_start : bool = False ,
414
419
stack_level : int = 2 ,
415
420
) -> WorkflowHandle [Any , Any ]:
416
421
"""Start a workflow and return its handle.
@@ -445,6 +450,10 @@ async def start_workflow(
445
450
rpc_metadata: Headers used on the RPC call. Keys here override
446
451
client-level RPC metadata keys.
447
452
rpc_timeout: Optional RPC deadline to set for the RPC call.
453
+ request_eager_start: Potentially reduce the latency to start this workflow by
454
+ encouraging the server to start it on a local worker running with
455
+ this same client.
456
+ This is currently experimental.
448
457
449
458
Returns:
450
459
A workflow handle to the started workflow.
@@ -492,6 +501,7 @@ async def start_workflow(
492
501
ret_type = result_type ,
493
502
rpc_metadata = rpc_metadata ,
494
503
rpc_timeout = rpc_timeout ,
504
+ request_eager_start = request_eager_start ,
495
505
)
496
506
)
497
507
@@ -521,6 +531,7 @@ async def execute_workflow(
521
531
start_signal_args : Sequence [Any ] = [],
522
532
rpc_metadata : Mapping [str , str ] = {},
523
533
rpc_timeout : Optional [timedelta ] = None ,
534
+ request_eager_start : bool = False ,
524
535
) -> ReturnType :
525
536
...
526
537
@@ -551,6 +562,7 @@ async def execute_workflow(
551
562
start_signal_args : Sequence [Any ] = [],
552
563
rpc_metadata : Mapping [str , str ] = {},
553
564
rpc_timeout : Optional [timedelta ] = None ,
565
+ request_eager_start : bool = False ,
554
566
) -> ReturnType :
555
567
...
556
568
@@ -583,6 +595,7 @@ async def execute_workflow(
583
595
start_signal_args : Sequence [Any ] = [],
584
596
rpc_metadata : Mapping [str , str ] = {},
585
597
rpc_timeout : Optional [timedelta ] = None ,
598
+ request_eager_start : bool = False ,
586
599
) -> ReturnType :
587
600
...
588
601
@@ -615,6 +628,7 @@ async def execute_workflow(
615
628
start_signal_args : Sequence [Any ] = [],
616
629
rpc_metadata : Mapping [str , str ] = {},
617
630
rpc_timeout : Optional [timedelta ] = None ,
631
+ request_eager_start : bool = False ,
618
632
) -> Any :
619
633
...
620
634
@@ -645,6 +659,7 @@ async def execute_workflow(
645
659
start_signal_args : Sequence [Any ] = [],
646
660
rpc_metadata : Mapping [str , str ] = {},
647
661
rpc_timeout : Optional [timedelta ] = None ,
662
+ request_eager_start : bool = False ,
648
663
) -> Any :
649
664
"""Start a workflow and wait for completion.
650
665
@@ -674,6 +689,7 @@ async def execute_workflow(
674
689
start_signal_args = start_signal_args ,
675
690
rpc_metadata = rpc_metadata ,
676
691
rpc_timeout = rpc_timeout ,
692
+ request_eager_start = request_eager_start ,
677
693
stack_level = 3 ,
678
694
)
679
695
).result ()
@@ -1082,6 +1098,7 @@ def __init__(
1082
1098
self ._result_run_id = result_run_id
1083
1099
self ._first_execution_run_id = first_execution_run_id
1084
1100
self ._result_type = result_type
1101
+ self .__temporal_eagerly_started = False
1085
1102
1086
1103
@property
1087
1104
def id (self ) -> str :
@@ -4282,6 +4299,7 @@ class StartWorkflowInput:
4282
4299
ret_type : Optional [Type ]
4283
4300
rpc_metadata : Mapping [str , str ]
4284
4301
rpc_timeout : Optional [timedelta ]
4302
+ request_eager_start : bool
4285
4303
4286
4304
4287
4305
@dataclass
@@ -4751,6 +4769,8 @@ async def start_workflow(
4751
4769
)
4752
4770
else :
4753
4771
req = temporalio .api .workflowservice .v1 .StartWorkflowExecutionRequest ()
4772
+ req .request_eager_execution = input .request_eager_start
4773
+
4754
4774
req .namespace = self ._client .namespace
4755
4775
req .workflow_id = input .id
4756
4776
req .workflow_type .name = input .workflow
@@ -4794,6 +4814,7 @@ async def start_workflow(
4794
4814
temporalio .api .workflowservice .v1 .StartWorkflowExecutionResponse ,
4795
4815
]
4796
4816
first_execution_run_id = None
4817
+ eagerly_started = False
4797
4818
try :
4798
4819
if isinstance (
4799
4820
req ,
@@ -4813,6 +4834,7 @@ async def start_workflow(
4813
4834
timeout = input .rpc_timeout ,
4814
4835
)
4815
4836
first_execution_run_id = resp .run_id
4837
+ eagerly_started = resp .HasField ("eager_workflow_task" )
4816
4838
except RPCError as err :
4817
4839
# If the status is ALREADY_EXISTS and the details can be extracted
4818
4840
# as already started, use a different exception
@@ -4826,13 +4848,15 @@ async def start_workflow(
4826
4848
)
4827
4849
else :
4828
4850
raise
4829
- return WorkflowHandle (
4851
+ handle : WorkflowHandle [ Any , Any ] = WorkflowHandle (
4830
4852
self ._client ,
4831
4853
req .workflow_id ,
4832
4854
result_run_id = resp .run_id ,
4833
4855
first_execution_run_id = first_execution_run_id ,
4834
4856
result_type = input .ret_type ,
4835
4857
)
4858
+ setattr (handle , "__temporal_eagerly_started" , eagerly_started )
4859
+ return handle
4836
4860
4837
4861
async def cancel_workflow (self , input : CancelWorkflowInput ) -> None :
4838
4862
await self ._client .workflow_service .request_cancel_workflow_execution (
0 commit comments