Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.

Make Sleep check for cancelled context every second #798

Merged
merged 3 commits into from
Aug 8, 2019

Conversation

juanjux
Copy link
Contributor

@juanjux juanjux commented Aug 7, 2019

Fixes #797

Signed-off-by: Juanjo Alvarez [email protected]

@juanjux
Copy link
Contributor Author

juanjux commented Aug 7, 2019

Updated to use better solution by @creachadair, thanks!

@juanjux juanjux requested a review from a team August 7, 2019 17:23
@juanjux juanjux self-assigned this Aug 7, 2019
Signed-off-by: Juanjo Alvarez <[email protected]>

Fix time scale

Signed-off-by: Juanjo Alvarez <[email protected]>

Multiply duration for sleep inside the parents

Signed-off-by: Juanjo Alvarez <[email protected]>

Multiply duration for sleep inside the parents

Signed-off-by: Juanjo Alvarez <[email protected]>
time.Sleep(time.Duration(child.(float64)*1000) * time.Millisecond)
return 0, nil
select {
case <-time.After(time.Duration(child.(float64) * 1000) * time.Millisecond):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would create a timer using time.NewTimer instead and then defer timer.Stop() so that we don't leave potentially long-running timers running unnecessarily.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@ajnavarro ajnavarro merged commit 4eaee9b into src-d:master Aug 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sleep function cannot be cancelled
4 participants