Skip to content

Commit f6784a9

Browse files
authored
Change Blocking to use Sync#interruptible, not blocking (#1126)
This is to avoid being unable to cancel code that is inside blocking section. At the moment it is possible for user-code to not cancel immediately, in which case it will block until an internal Kafka max-block period is reached (by default 1 minute). Changing to use `interruptible` means the user-code returns immediately on cancellation, and the underlying operation in Kafka should be cancelled.
1 parent 4e47aaf commit f6784a9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

modules/core/src/main/scala/fs2/kafka/internal/Blocking.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ private[kafka] trait Blocking[F[_]] {
2020
private[kafka] object Blocking {
2121

2222
def fromSync[F[_]: Sync]: Blocking[F] = new Blocking[F] {
23-
override def apply[A](a: => A): F[A] = Sync[F].blocking(a)
23+
override def apply[A](a: => A): F[A] = Sync[F].interruptible(a)
2424
}
2525

2626
def fromExecutionContext[F[_]](ec: ExecutionContext)(implicit F: Async[F]): Blocking[F] =

0 commit comments

Comments
 (0)