You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
run_app() provides a simple blocking API for running an Application.
For starting the application asynchronously or serving on multiple HOST/PORT AppRunner exists.
No up to date example exists however on how exactly to implement the truly async server
Expected behaviour
Replicating the example doesn't cause DeprecationWarning: loop argument is deprecated
Actual behaviour
Replicating the example causes DeprecationWarning: loop argument is deprecated
Steps to reproduce
Replicating the example found linked above. Or in my exact case:
server.py
import asyncio
from multidict import MultiDictProxy
from aiohttp import web
routes = web.RouteTableDef()
loop = asyncio.get_event_loop()
class Server:
def __init__(self, *, inner_loop):
self.loop = inner_loop
self.app = web.Application(loop=loop)
self.app.add_routes(routes)
self.runner = None
async def start(self):
port = 40509
self.runner = web.AppRunner(self.app)
await self.runner.setup()
site = web.TCPSite(self.runner, port=port)
await site.start()
@routes.get('/')
async def on_query(self, request):
query: MultiDictProxy = request.query.get('q')
await asyncio.sleep(5)
if query:
return web.json_response({'query': query})
return web.json_response({})
async def main(main_loop):
server = Server(inner_loop=main_loop)
await server.start()
try:
loop.run_until_complete(main(loop))
except KeyboardInterrupt:
loop.close()
Long story short
https://github.com/aio-libs/aiohttp/blob/master/examples/fake_server.py#L37 is outdated.
https://docs.aiohttp.org/en/stable/web_advanced.html#application-runners states that:
No up to date example exists however on how exactly to implement the truly async server
Expected behaviour
Replicating the example doesn't cause
DeprecationWarning: loop argument is deprecated
Actual behaviour
Replicating the example causes
DeprecationWarning: loop argument is deprecated
Steps to reproduce
Replicating the example found linked above. Or in my exact case:
server.py
requirements.py
Dockerfile
Then run
docker build . -t py-whois && docker run py-whois
Your environment
Docker image python:3.7.3-alpine3.9 (see above)
The text was updated successfully, but these errors were encountered: