I used python before, and I converted one of the h...
# coroutines
d
I used python before, and I converted one of the http servers that I had into async/await app, I used async libraries like aiopg or aiohttp. But say I have jdbi/jdbc based app, how do I convert it into async using coroutines without an async library or spawning any additional threads?
t
you cannot convert blocking call to async without explicit or implicit threads; simple option is smth like
fun asyncCall() = async(IO) { blockingCall() }
d
I just wonder how it’s done in python, I don’t think it spawns any threads
say you make 1000 long standing http calls and you await for them, will kotlin spawn up 1000 threads?
I guess you control number of threads with thread executor, but if a coroutine requires a thread to perform that http call, what is the point of coroutine at all?
t
aiohttp is built as async from scratch, you can check kotlinx-io or ktor as sample of similar approach implementation in kotlin
d
aiopg though is just an async wrapper around blocking psycopg library, so I was looking for an example of how to do similar thing in kotlin
will have a look at kotlin-x and ktor, thanks