Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: gather() got an unexpected keyword argument 'loop' (Python 3.10+) #5996

Closed
1 task done
eXhumer opened this issue Sep 12, 2021 · 4 comments
Closed
1 task done
Labels

Comments

@eXhumer
Copy link

eXhumer commented Sep 12, 2021

Describe the bug

asyncio.gather's loop keyword argument has been deprecated since 3.8+ and is scheduled to remove from 3.10+ (3.10 due to release in less than a month, final release candidate already published). Using Ctrl + C to quit server provides the error traceback which indicates a problem with _cancel_tasks method in web module of the aiohttp package.

To Reproduce

  1. Start a new server with the following code snippet.
from aiohttp.web import (
    Application,
    get as get_route,
    Response,
    Request,
    run_app,
)


async def hello(request: Request) -> Response:
    name = request.match_info.get('name', "Anonymous")
    return Response(text=f"Hello, {name}")


if __name__ == '__main__':
    app = Application()
    app.add_routes([
        get_route("/{name}", hello),
    ])
    run_app(app)
  1. Use Ctrl + C to shut down server.

Expected behavior

For running server to exit cleanly.

Logs/tracebacks

Traceback (most recent call last):  File "C:\Users\eXhumer\Projects\AIOHTTPServer\server.py", line 15, in <module>
    run_app(app)  File "C:\Users\eXhumer\Projects\AIOHTTPServer-env\lib\site-packages\aiohttp\web.py", line 512, in run_app
    _cancel_tasks({main_task}, loop)  File "C:\Users\eXhumer\Projects\AIOHTTPServer-env\lib\site-packages\aiohttp\web.py", line 444, in _cancel_tasks
    asyncio.gather(*to_cancel, loop=loop, return_exceptions=True)
TypeError: gather() got an unexpected keyword argument 'loop'

Python Version

Python 3.10.0rc2

aiohttp Version

Name: aiohttp
Version: 3.7.4.post0
Summary: Async http client/server framework (asyncio)
Home-page: https://github.com/aio-libs/aiohttp
Author: Nikolay Kim
Author-email: [email protected]
License: Apache 2
Location: c:\users\exhumer\projects\aiohttpserver-env\lib\site-packages
Requires: chardet, yarl, typing-extensions, async-timeout, attrs, multidict
Required-by:

multidict Version

Name: multidict
Version: 5.1.0
Summary: multidict implementation
Home-page: https://github.com/aio-libs/multidict
Author: Andrew Svetlov
Author-email: [email protected]
License: Apache 2
Location: c:\users\exhumer\projects\aiohttpserver-env\lib\site-packages
Requires:
Required-by: yarl, aiohttp

yarl Version

Name: yarl
Version: 1.6.3
Summary: Yet another URL library
Home-page: https://github.com/aio-libs/yarl/
Author: Andrew Svetlov
Author-email: [email protected]
License: Apache 2
Location: c:\users\exhumer\projects\aiohttpserver-env\lib\site-packages
Requires: multidict, idna
Required-by: aiohttp

OS

Windows 11 Pro (Build 22454.rs_prerelease.210903-1516)

Related component

Server

Additional context

No response

Code of Conduct

  • I agree to follow the aio-libs Code of Conduct
@eXhumer eXhumer added the bug label Sep 12, 2021
@webknjaz
Copy link
Member

The 3.7.x stream of aiohttp will not get any updates so don't expect it to ever get support for . Besides, it still supports Python 3.6 which, I think, still requires an explicit loop arg. The master branch (aiohttp 4.0+) has already dropped py36 so it should be fine to start a crusade of dropping the use of loop across the code base.
Also, Python 3.6 goes EOL in 3 months so I suppose it'd be reasonable to drop py36 for the next aiohttp 3.8.x stream and get such the patch backported from master then.

cc @aio-libs/aiohttp-dev WDYT?

@Dreamsorcerer
Copy link
Member

No, it doesn't, we've already removed it in 3.8 in response to the last person who said it was broken in 3.10. The only reason it's not updated in 3.7 is because python was not emitting DeprecationWarnings in some cases (for this one, it only emitted a warning when asyncio.gather() was called with no tasks. Probably not the typical usecase. :P).

See my comment at #5991 (comment)
And the previous bug report: #5905

I'm fine with dropping python 3.6, but this is not a requirement as it is working fine in the 3.8 branch already.

@webknjaz
Copy link
Member

Great! We need to make sure that our CI/CD pipeline produces platform-specific wheels for py310. Would you like to work on this?

@Dreamsorcerer
Copy link
Member

Great! We need to make sure that our CI/CD pipeline produces platform-specific wheels for py310. Would you like to work on this?

To be honest, I don't even know what that would involve.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants