I want to take input from console in 3 seconds, otherwise in timeout case return "Timeout!"
. I wrote this function:
def withTimeout: IO[String] =
Console[IO].readLine.timeoutTo(3.seconds, IO.pure("Timeout!"))
But it doesn't stop after 3 seconds, but waits any input, and only after input returns "Timeout!"
. Is this happens because Console
is not cancellable? How can I solve this issue?