The proposal allows to execute async IO before creating an application
How does this differ from on_startup?
Surely too many options will for the default way to run a server will confuse new users?
It follows new asyncio API: https://docs.python.org/3.7/library/asyncio-task.html#asyncio.asyncio.run
Sounds reasonable, I'd like to see the implementation draft for it.
The change is easy:
if asyncio.iscoroutine(app):
app = await app
in very beginning of run_app function.
Any volunteer?
it's say try/except instead
try:
app = await app
except TypeError:
pass
looks really strange for me
but follows EAFP
It is not forgiveness/permission problem but overloading accepted types.
In static typed language it should be two functions with the same name but different parameter types.
yeah, and there's functools.dispatch() for that it Python
singledispatch actually - that's the problem
would this feature allow you to run the app asynchronously? in other words an async equivalent of the aiohttp.web.run_app function?
@chuck1 no. run_app instantiates and closes an event loop instance.
But you can run an app from in a coroutine by three lines of code, 2 for initializing and 1 for shutdown: https://docs.aiohttp.org/en/stable/web_advanced.html#application-runners
Done by #2765
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a [new issue] for related bugs.
If you feel like there's important points made in this discussion, please include those exceprts into that [new issue].