@@ -155,6 +155,7 @@ def get_activity():
155155 "decision_task_completed_event_id" : event .decision_task_completed_event_id ,
156156 }
157157 if event .activity_id not in self ._activities :
158+ activity ["retry" ] = 0
158159 self ._activities [event .activity_id ] = activity
159160 self ._tasks .append (activity )
160161 else :
@@ -164,6 +165,7 @@ def get_activity():
164165 # in ``retry``. As the state of the event mutates, it
165166 # corresponds to the last execution.
166167 self ._activities [event .activity_id ].update (activity )
168+ self ._activities [event .activity_id ]["retry" ] += 1
167169 elif event .state == "schedule_failed" :
168170 activity = {
169171 "type" : "activity" ,
@@ -218,10 +220,6 @@ def get_activity():
218220 "timed_out_timestamp" : event .timestamp ,
219221 }
220222 )
221- if "retry" not in activity :
222- activity ["retry" ] = 0
223- else :
224- activity ["retry" ] += 1
225223 elif event .state == "failed" :
226224 activity = get_activity ()
227225 activity .update (
@@ -233,10 +231,6 @@ def get_activity():
233231 "failed_timestamp" : event .timestamp ,
234232 }
235233 )
236- if "retry" not in activity :
237- activity ["retry" ] = 0
238- else :
239- activity ["retry" ] += 1
240234 elif event .state == "cancelled" :
241235 activity = get_activity ()
242236 activity .update (
@@ -310,6 +304,7 @@ def get_workflow():
310304 "decision_task_completed_event_id" : event .decision_task_completed_event_id ,
311305 }
312306 if event .workflow_id not in self ._child_workflows :
307+ workflow ["retry" ] = 0
313308 self ._child_workflows [event .workflow_id ] = workflow
314309 self ._tasks .append (workflow )
315310 else :
@@ -322,6 +317,7 @@ def get_workflow():
322317 f" we're @{ event .id } )"
323318 )
324319 self ._child_workflows [event .workflow_id ].update (workflow )
320+ self ._child_workflows [event .workflow_id ]["retry" ] += 1
325321 elif event .state == "start_failed" :
326322 workflow = {
327323 "type" : "child_workflow" ,
@@ -372,10 +368,6 @@ def get_workflow():
372368 "failed_timestamp" : event .timestamp ,
373369 }
374370 )
375- if "retry" not in workflow :
376- workflow ["retry" ] = 0
377- else :
378- workflow ["retry" ] += 1
379371 elif event .state == "timed_out" :
380372 workflow = get_workflow ()
381373 workflow .update (
@@ -391,10 +383,6 @@ def get_workflow():
391383 "timed_out_timestamp" : event .timestamp ,
392384 }
393385 )
394- if "retry" not in workflow :
395- workflow ["retry" ] = 0
396- else :
397- workflow ["retry" ] += 1
398386 elif event .state == "canceled" :
399387 workflow = get_workflow ()
400388 workflow .update (
0 commit comments