I am working with MockWebServer and it has a function MockWebServer.takeRequest() which block execution endlessly until request is presented. Is it still good to just use IO thread pool for this ? I ve read Dispatcher.IO expect threads to do job, and finish eventialy. The question is - how do u handle such designed functions from blocking libraries (functions with possible endless blocking).
s
stojan
06/04/2024, 11:09 AM
you can use
Copy code
server.takeRequest(1, TimeUnit.SECONDS);
(and adjust the timeout to your need) In unit tests I would normally call that function as it is, without wrapping it with coroutines.