Hi all, I try to implement an async request to a k...
# ktor
Hi all, I try to implement an async request to a ktor-Server which shall respond directly and then start the async task. It is possible to do it like:
Copy code
put<MyRoute> {
This returns the response directly and the synchronous task seems to run until the end. Does every call already run in a separated thread or do I have to start a new thread for the runTask()?
You have a separate coroutine running for every request
But I’d recommend to launch a new for background tasks
okay, so it would work but it's not the way I should use it, right?
right, because it is tied to the request and it will not complete until the coroutine is running
could potentially lead to some strange consequences
don’t think it will break anything unless you are doing something blocking
so to be sure, I would run a separate coroutine
notice the difference: coroutine vs thread
Okay, thank you very much. 👍