Currently, there is no non-blocking way to start the server in the same thread/loop, because App.run starts the loop itself. Ideally, App.run would be a coroutine and leave starting the loop to the user of the library
Doing things this way allows for greater flexibility, and allows other libraries to use the loop (e.g. another server running asynchronously along side japronto)
Currently, there is no non-blocking way to start the server in the same thread/loop, because
App.run
starts the loop itself. Ideally,App.run
would be a coroutine and leave starting the loop to the user of the libraryHowever, another way to achieve this would be to have a
App.create_serve_coro
function (based on https://github.com/squeaky-pl/japronto/blob/master/src/japronto/app/__init__.py#L154 andApp.run
) which returns a ready made coroutine for passing to the loop, instead of starting the loop itself.Doing things this way allows for greater flexibility, and allows other libraries to use the loop (e.g. another server running asynchronously along side japronto)
(This is a similar issue to https://github.com/channelcat/sanic/issues/275 where there's more discussion on pros/cons of this approach)