I am trying to use coroutines with connections. However,
connections uses blocking (
I think)... this effectively makes each coroutine the same as a thread. Is there anyway to turn these API `sleep()`s into `delay()`s?
04/17/2018, 1:15 AM
No, it’s impossible, you cannot magically convert blocking calls to non-blocking.
The only way is wrap blocking API with own coroutine that uses custom coroutines dispatcher (to avoid blocking of CommonPool dispatcher)
Or use async API/library.
Why does Jsoup use Thread.sleep()?
Maybe to avoid blocking just do not use Jsoup API that reads document from network and do that using some async http client.
Or, after all just, wrap those sync calls to coroutine with own thread pool