Skip to content

Commit

Permalink
fixed issue with disposing CancellationTokenSource
Browse files Browse the repository at this point in the history
  • Loading branch information
AntyaDev committed Sep 21, 2022
1 parent d4d9cb9 commit c063cd2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/NBomber/Domain/Step.fs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ module RunningStep =

| _ -> Unchecked.defaultof<_>

let updateContext (step: RunningStep) (data: Dictionary<string,obj>) =
let updateContext (step: RunningStep) (data: Dictionary<string,obj>) (cancelToken: CancellationTokenSource) =
let st = step.Value
let context = step.Context

Expand All @@ -136,7 +136,7 @@ module RunningStep =
| Some feed -> feed.GetNextItem(context.ScenarioInfo, data)
| None -> Unchecked.defaultof<_>

context.CancellationTokenSource <- new CancellationTokenSource()
context.CancellationTokenSource <- cancelToken
context.InvocationNumber <- context.InvocationNumber + 1
context.Data <- data
context.FeedItem <- feedItem
Expand Down Expand Up @@ -214,7 +214,8 @@ module RunningStep =
&& not dep.ScenarioDep.ScenarioCancellationToken.IsCancellationRequested
&& dep.ScenarioInfo.ScenarioDuration.TotalMilliseconds > (dep.ScenarioDep.ScenarioTimer.Elapsed.TotalMilliseconds + Constants.SchedulerTimerDriftMs) then

let step = updateContext steps[stepIndex] dep.Data
use cancelToken = new CancellationTokenSource()
let step = updateContext steps[stepIndex] dep.Data cancelToken
let! response = execStep dep step

if response.IsError then
Expand Down

0 comments on commit c063cd2

Please sign in to comment.