@@ -121,53 +121,54 @@ async def main():
121121 wfr .start ()
122122 wf_client = DaprWorkflowClient ()
123123
124- print ('==========Start Counter Increase as per Input:==========' )
125- await wf_client .schedule_new_workflow (
126- workflow = hello_world_wf , input = input_data , instance_id = instance_id
127- )
128-
129- await wf_client .wait_for_workflow_start (instance_id )
130-
131- # Sleep to let the workflow run initial activities
132- await asyncio .sleep (12 )
133-
134- assert counter == 11
135- assert retry_count == 2
136- assert child_orchestrator_string == '1aa2bb3cc'
137-
138- # Pause Test
139- await wf_client .pause_workflow (instance_id = instance_id )
140- metadata = await wf_client .get_workflow_state (instance_id = instance_id )
141- print (f'Get response from { workflow_name } after pause call: { metadata .runtime_status .name } ' )
142-
143- # Resume Test
144- await wf_client .resume_workflow (instance_id = instance_id )
145- metadata = await wf_client .get_workflow_state (instance_id = instance_id )
146- print (f'Get response from { workflow_name } after resume call: { metadata .runtime_status .name } ' )
147-
148- await asyncio .sleep (2 ) # Give the workflow time to reach the event wait state
149- await wf_client .raise_workflow_event (
150- instance_id = instance_id , event_name = event_name , data = event_data
151- )
152-
153- print ('========= Waiting for Workflow completion' , flush = True )
154124 try :
155- state = await wf_client .wait_for_workflow_completion (instance_id , timeout_in_seconds = 30 )
156- if state .runtime_status .name == 'COMPLETED' :
157- print ('Workflow completed! Result: {}' .format (state .serialized_output .strip ('"' )))
158- else :
159- print (f'Workflow failed! Status: { state .runtime_status .name } ' )
160- except TimeoutError :
161- print ('*** Workflow timed out!' )
162-
163- await wf_client .purge_workflow (instance_id = instance_id )
164- try :
165- await wf_client .get_workflow_state (instance_id = instance_id )
166- except DaprInternalError as err :
167- if non_existent_id_error in err ._message :
168- print ('Instance Successfully Purged' )
169-
170- wfr .shutdown ()
125+ print ('==========Start Counter Increase as per Input:==========' )
126+ await wf_client .schedule_new_workflow (
127+ workflow = hello_world_wf , input = input_data , instance_id = instance_id
128+ )
129+
130+ await wf_client .wait_for_workflow_start (instance_id )
131+
132+ # Sleep to let the workflow run initial activities
133+ await asyncio .sleep (12 )
134+
135+ assert counter == 11
136+ assert retry_count == 2
137+ assert child_orchestrator_string == '1aa2bb3cc'
138+
139+ # Pause Test
140+ await wf_client .pause_workflow (instance_id = instance_id )
141+ metadata = await wf_client .get_workflow_state (instance_id = instance_id )
142+ print (f'Get response from { workflow_name } after pause call: { metadata .runtime_status .name } ' )
143+
144+ # Resume Test
145+ await wf_client .resume_workflow (instance_id = instance_id )
146+ metadata = await wf_client .get_workflow_state (instance_id = instance_id )
147+ print (f'Get response from { workflow_name } after resume call: { metadata .runtime_status .name } ' )
148+
149+ await asyncio .sleep (2 ) # Give the workflow time to reach the event wait state
150+ await wf_client .raise_workflow_event (
151+ instance_id = instance_id , event_name = event_name , data = event_data
152+ )
153+
154+ print ('========= Waiting for Workflow completion' , flush = True )
155+ try :
156+ state = await wf_client .wait_for_workflow_completion (instance_id , timeout_in_seconds = 30 )
157+ if state .runtime_status .name == 'COMPLETED' :
158+ print ('Workflow completed! Result: {}' .format (state .serialized_output .strip ('"' )))
159+ else :
160+ print (f'Workflow failed! Status: { state .runtime_status .name } ' )
161+ except TimeoutError :
162+ print ('*** Workflow timed out!' )
163+
164+ await wf_client .purge_workflow (instance_id = instance_id )
165+ try :
166+ await wf_client .get_workflow_state (instance_id = instance_id )
167+ except DaprInternalError as err :
168+ if non_existent_id_error in err ._message :
169+ print ('Instance Successfully Purged' )
170+ finally :
171+ wfr .shutdown ()
171172
172173
173174if __name__ == '__main__' :
0 commit comments