TypeError: _patch_task.<locals>.task_new_init() got an unexpected keyword argument 'eager_start'
zhoutaoq opened this issue · comments
Describe the bug
When I use pycharm to start the program in debug mode, the initiating request gets an error that doesn't work. The error stack is as follows:
Exception ignored in: <function Task.__del__ at 0x000001757AF74F40> Traceback (most recent call last): File "D:\python12\Lib\asyncio\tasks.py", line 150, in __del__ self._loop.call_exception_handler(context) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'call_exception_handler' Unhandled exception Traceback (most recent call last): File "D:\Python\github\niututu\.venv\Lib\site-packages\aiohttp\web_protocol.py", line 536, in start task = asyncio.Task(coro, loop=loop, eager_start=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: _patch_task.<locals>.task_new_init() got an unexpected keyword argument 'eager_start'
When I started it in running mode, it worked fine
After tracing the source code, I changed this line to task = asyncio.Task(coro, loop=loop)
so that it will work again when started in debug mode
task = asyncio.Task(coro, loop=loop, eager_start=True)
python version = 3.12.1
aiohttp version = 3.10.5
To Reproduce
See above description
Expected behavior
See above description
Logs/tracebacks
See above description
Python Version
3.12.1
aiohttp Version
3.10.5
multidict Version
6.0.5
yarl Version
1.9.4
OS
windows 11
Related component
Server
Additional context
No response
Code of Conduct
- I agree to follow the aio-libs Code of Conduct
If you think the problem is in our code, then you need to provide a reproducer, but we're just calling asyncio.Task
. The error suggests you've managed to patch the call with something incompatible:
TypeError: _patch_task.<locals>.task_new_init()
I don't believe this task_new_init() comes from our code, or cpython...
It looks like whatever you have patching asyncio.Task
is not python 3.12 aware.
I tried to use the local environment interpreter in pycharm and it helped me work properly, so it really wasn't an aiohttp problem, but I couldn't find out why because the local environment and the virtual environment looked exactly the same. thanks for your help!
I have the same error.
The solution is reported here: https://stackoverflow.com/a/77908985/592348
It's a param to change in PyCharm
Thank you very much! What you said is right. I modified the configuration according to the document, and it can be started by debugging mode.
@sylvainmouquet Thank you!