Skip to content

Commit bb2a182

Browse files
committed
wip fix race condition in AI code
1 parent 3eafa6f commit bb2a182

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

twitter-futures/src/test/scala/com/dwolla/util/async/twitter/TwitterFutureAsyncMapKTests.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ class TwitterFutureAsyncMapKTests extends CatsEffectSuite with ScalaCheckEffectS
3232
test("cancelling a running Twitter Future lifted into IO should interrupt the underlying Twitter Future") {
3333
for {
3434
promise <- IO(Promise[Int]())
35-
fiber <- liftFuture[IO](IO.pure(promise)).start
35+
startedLatch <- CountDownLatch[IO](1)
36+
fiber <- IO.uncancelable { poll => // we only want the Future to be cancellable
37+
poll(liftFuture[IO](startedLatch.release.as(promise))).start
38+
}
39+
_ <- startedLatch.await
3640
_ <- fiber.cancel
3741
} yield {
3842
assert(promise.isInterrupted.isDefined)

0 commit comments

Comments
 (0)