-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
RuntimeError: no running event loop #8555
Comments
It looks like it was deprecated in 3.9.5 and now no longer works in 3.10.0 https://github.com/aio-libs/aiohttp/blob/3.9/aiohttp/helpers.py#L296 but #5278 didn't have a changelog message to say it would stop working. In 3.9.5 it would create a new non-running event loop
|
Based on the above, I'd say the change is intentional but could use a changelog entry. |
Creating a |
is this going to be fixed in 3.10.1 ? or is this breakage intentional? |
The only planned change is to improve the changelog. As it was deprecated over 5 years ago, there is no plan to extend the deprecation period. Edit: This practice is deprecated in Python as well https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.get_event_loop |
This is a breaking change (intentional or not), so shouldn't the version be bumped to 4.0.0? Regardless of the length of the deprecation period. |
@webknjaz That's a bit passive-aggressive. I know I shouldn't blindly trust any package I use, but sematic versioning best pratices would be a nice touch for such a widely used package as aiohttp. I don't think you are excused just because you can link to a blog post that says it's the user's fault. |
I thought about a partial revert of #8512 (originally #5278) on 3.10/3.11, but I'm not sold on that idea because Python has deprecated calling https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.get_event_loop |
aiohttp's new 3.10.0 stops supporting creating ClientSession in non async context any more. aio-libs/aiohttp#8555 (comment) --------- Signed-off-by: Rui Qiao <ruisearch42@gmail.com>
@TheDurableDane you're right the end-users should be able to rely on the documented expectations. Could you point out where we promise that the first version component alone corresponds to SemVer's major version? My observation is that major has always two components. |
Just to add to bdraco's conclusion, I think the old code may have been dangerously wrong in some situations. |
0001-Restore-the-ability-to-create-objects-without-a-runn.patch Attached is a patch for anyone who arrives at this issue in the future because a security |
Can confirm this works on my Windows 10 machine:
however got this working by manual alterations.
Note: Here is the log on the build attempt...
|
This may help import aiohttp
import asyncio
async def create_session():
return aiohttp.ClientSession()
aiohttp_client_session = asyncio.get_event_loop().run_until_complete(create_session()) |
As mentioned above, very likely to break your application (now or in the future). |
Since `aiohttp==0.20.0`, instantiating `aiohttp.ClientSession` must be done from an async function. Calling this from a non-async function relied on deprecated behaviour in Python, which broke in recent releases. aio-libs/aiohttp#8555 (comment) explains the situation. Rather than pin `aiohttp` to an older version, let's just fix the behaviour.
Since `aiohttp==3.10.0`, instantiating `aiohttp.ClientSession` must be done from an async function. Calling this from a non-async function relied on deprecated behaviour in Python, which broke in recent releases. aio-libs/aiohttp#8555 (comment) explains the situation. Rather than pin `aiohttp` to an older version, let's just fix the behaviour.
Since `aiohttp==3.10.0`, instantiating `aiohttp.ClientSession` must be done from an async function. Calling this from a non-async function relied on deprecated behaviour in Python, which broke in recent releases. aio-libs/aiohttp#8555 (comment) explains the situation. Rather than pin `aiohttp` to an older version, let's just fix the behaviour.
Since `aiohttp==3.10.0`, instantiating `aiohttp.ClientSession` must be done from an async function. Calling this from a non-async function relied on deprecated behaviour in Python, which broke in recent releases. aio-libs/aiohttp#8555 (comment) explains the situation. Rather than pin `aiohttp` to an older version, let's just fix the behaviour.
Since `aiohttp==3.10.0`, instantiating `aiohttp.ClientSession` must be done from an async function. Calling this from a non-async function relied on deprecated behaviour in Python, which broke in recent releases. aio-libs/aiohttp#8555 (comment) explains the situation. Rather than pin `aiohttp` to an older version, let's just fix the behaviour.
aiohttp dropped support for the deprecated in Python 3.12 method [`get_event_loop()`](https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.get_event_loop): aio-libs/aiohttp#8555 In this PR I am adapting the logic to these changes.
Describe the bug
It looks like a breaking change in the latest version.
In version 3.9.5 it works:
(in a more complex example I get a warning (DeprecationWarning: The object should be created within an async function))
but in 3.10 I get an exception:
To Reproduce
code
Expected behavior
If the change is intentional it would be very useful to describe that in a changelog.
If not I expect the same behavior like in the previous version.
Logs/tracebacks
aiohttp Version
multidict Version
yarl Version
OS
Linux
Related component
Client
Additional context
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: