Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #3898 for Dispatcher.parallel #3900

Merged
merged 3 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion std/shared/src/main/scala/cats/effect/std/Dispatcher.scala
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ object Dispatcher {
fork(action).flatMap(cancel => F.delay(prepareCancel(cancel)))

// Check for task cancelation before executing.
F.delay(r.get()).ifM(supervise, F.unit)
F.delay(r.get()).ifM(supervise, F.delay(prepareCancel(F.unit)))
}
}
} yield ()
Expand Down
13 changes: 13 additions & 0 deletions tests/shared/src/test/scala/cats/effect/std/DispatcherSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,19 @@ class DispatcherSpec extends BaseSpec with DetectPlatform {

TestControl.executeEmbed(rec.use(_ => IO(canceled must beTrue)))
}

// https://github.com/typelevel/cats-effect/issues/3898
"not hang when cancelling" in real {
dispatcher.use { dispatcher =>
IO.fromFuture {
IO {
val (_, cancel) = dispatcher.unsafeToFutureCancelable(IO.never)
cancel()
}
}.replicateA_(1000)
.as(ok)
}
}
}

private def common(dispatcher: Resource[IO, Dispatcher[IO]]) = {
Expand Down
Loading