Skip to content

Commit 7254208

Browse files
alexshtinmeiliang86
authored andcommitted
Cancel context to free resources (#147)
1 parent 1485006 commit 7254208

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

internal/internal_task_handlers.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1767,6 +1767,7 @@ func (ath *activityTaskHandlerImpl) Execute(taskList string, t *s.PollForActivit
17671767
rootCtx = context.Background()
17681768
}
17691769
canCtx, cancel := context.WithCancel(rootCtx)
1770+
defer cancel()
17701771

17711772
invoker := newServiceInvoker(t.TaskToken, ath.identity, ath.service, cancel, t.GetHeartbeatTimeoutSeconds(), ath.workerStopCh)
17721773
defer func() {
@@ -1813,6 +1814,7 @@ func (ath *activityTaskHandlerImpl) Execute(taskList string, t *s.PollForActivit
18131814

18141815
info := ctx.Value(activityEnvContextKey).(*activityEnvironment)
18151816
ctx, dlCancelFunc := context.WithDeadline(ctx, info.deadline)
1817+
defer dlCancelFunc()
18161818

18171819
ctx, span := createOpenTracingActivitySpan(ctx, ath.tracer, time.Now(), activityType, t.WorkflowExecution.GetWorkflowId(), t.WorkflowExecution.GetRunId())
18181820
defer span.Finish()

0 commit comments

Comments
 (0)