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
Python 3.13 will be available as an experimental free-threaded build that has the GIL disabled. It should hopefully be possible to build aiohttp on the free-threaded build with an updated Cython. I just did so (with some makefile hacking so the build uses a prerelease cython):
Python 3.13.0rc1 experimental free-threading build (main, Aug 14 2024, 13:20:46) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import aiohttp
<frozen importlib._bootstrap>:488: RuntimeWarning: The global interpreter lock (GIL) has been enabled to load module 'aiohttp._helpers', which has not declared that it can run safely without the GIL. To override this behavior and keep the GIL disabled (at your own risk), run with PYTHON_GIL=0 or -Xgil=0.
Reacted by Luca | Serenita, Edgar Ramírez Mondragón, Emmanuel Alap, Juhan Oskar Hennoste, Sergey Vasilyev, Quentin Pradet, Kostya Leschenko, Mohammadarshia Seyed Shakery, electroglyph, Filipp Ozinov and 9 more
If you'd like to help, I think the first thing would be to add a new test run to the CI, so we have some test coverage over this new approach. But, I'd assume the Cython code is likely thread-safe as it's just used for parsers.
Probably need the current 3.13 tests passing first though, which will hopefully happen next week after uvloop publish a 3.13 wheel.
I think that getting our in-org hosted deps to run CI / make builds might be another blocker. I think that aiohttp's CI should make use of those wheels rather than compiling them.
No, plenty of work has been done on aiohttp dependencies, so looks like it's shaping up for a release in the near future. Plenty of the ecosystem is still not ready for free-threaded, so it's not been a trivial change (e.g. needing to use an alpha release of Cython).
welp, i just built it for free-threaded on Windows. here's how I did it, i'm sure there will be opinions =)
there's surely a less hacky way to go with the macros...
i've only tested the http client, which works, but i get this msg, any pointers on how to remove this warning would be appreciated:
<frozen importlib._bootstrap>:488: RuntimeWarning: The global interpreter lock (GIL) has been enabled to load module 'aiohttp._http_writer', which has not declared that it can run safely without the GIL. To override this behavior and keep the GIL disabled (at your own risk), run with PYTHON_GIL=0 or -Xgil=0.
Well, the warning is because it doesn't support free-threading. Fixing the warning is done by supporting free-threading, i.e. what this issue tracks.
I think multidict and frozenlist have free-threading now, and yarl I believe is ready to merge and release. That'll probably be all the dependencies sorted, then it's just aiohttp itself that needs a similar update, so seems like it's getting close now.
Reacted by 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко)
I would assume an optional dependency is not a blocker to us. Maybe pycares will need an update? But, people can use it without aiodns until that becomes supported.
It looks like pycares uses CFFI, so that might require using our fork of CFFI to get that working. See python-cffi/cffi#143 (comment). I'll open an issue over at the pycares repo.
Thanks! This is because of the hacked-together, manually constructed environment.
This one looks weird. How can it be a closed file when we're attempting to open it?
On a second look, I agree. Maybe there's something tricky going on in the pathlib implementation along the lines of python/cpython#136248, which seems similar. I'll try to reproduce this outside of aiohttp.
Reacted by 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко)
I just re-did this exercise with a Python 3.14t interpreter. This required even more hacking of test dependencies, since a few of the dependencies in the test requirements file are pinned to versions that don't support 3.14.
With 3.14t, I no longer see the pathlib error I saw before. It's possible the fix for the issue I saw has been fixed in CPython main for a while and the fix was never backported to 3.13 - I'll try to pin that down so we can make sure there's a backport.
With 3.14t I see the following test failures and errors in the aiohttp tests:
I've added 3.14 back to the testing matrix. Looks like initial blockers are isal and pydantic-core. I think pydantic is already resolved, but Dependabot seems to think it's not upgradeable, so may need a manual version bump.
I've added 3.14 back to the testing matrix. Looks like initial blockers are isal and pydantic-core. I think pydantic is already resolved, but Dependabot seems to think it's not upgradeable, so may need a manual version bump.
I have updated my PR at #10872 to avoid installing isal and python-on-whales on 3.14 as they are test are only dependencies and skipped tests if not present, with that most tests are now passing except one in cookie jar which was changed in 3.14.
I think this is a good starting point to merge that than waiting for all such non-required dependencies to ship 3.14 wheels.
Looks like Pydantic should have a release in a few days, so we can wait that one out. If isal doesn't respond, then we'll have to consider your workarounds.
Activity
Dreamsorcerer commentedon Aug 20, 2024
If you'd like to help, I think the first thing would be to add a new test run to the CI, so we have some test coverage over this new approach. But, I'd assume the Cython code is likely thread-safe as it's just used for parsers.
Probably need the current 3.13 tests passing first though, which will hopefully happen next week after uvloop publish a 3.13 wheel.
webknjaz commentedon Aug 21, 2024
I think that getting our in-org hosted deps to run CI / make builds might be another blocker. I think that aiohttp's CI should make use of those wheels rather than compiling them.
Dreamsorcerer commentedon Sep 27, 2024
3.13 is fully tested and passing now, if anyone wants to look at adding the free-threading testing.
webknjaz commentedon Oct 18, 2024
@Yushu2606 what's your point? That doesn't seem related to the discussion here.
ngoldbaum commentedon Oct 18, 2024
@Yushu2606 you probably aren't building with a nightly cython. Right now there isn't a tagged cython version or release that supports free-threading.
patrizok commentedon Nov 13, 2024
mshakery commentedon Mar 7, 2025
Is this forgotten?
Dreamsorcerer commentedon Mar 7, 2025
No, plenty of work has been done on aiohttp dependencies, so looks like it's shaping up for a release in the near future. Plenty of the ecosystem is still not ready for free-threaded, so it's not been a trivial change (e.g. needing to use an alpha release of Cython).
electroglyph commentedon Apr 2, 2025
i'm interested, too. is there a list of free-threaded blockers that need to be addressed?
electroglyph commentedon Apr 2, 2025
welp, i just built it for free-threaded on Windows. here's how I did it, i'm sure there will be opinions =)
there's surely a less hacky way to go with the macros...
i've only tested the http client, which works, but i get this msg, any pointers on how to remove this warning would be appreciated:
<frozen importlib._bootstrap>:488: RuntimeWarning: The global interpreter lock (GIL) has been enabled to load module 'aiohttp._http_writer', which has not declared that it can run safely without the GIL. To override this behavior and keep the GIL disabled (at your own risk), run with PYTHON_GIL=0 or -Xgil=0.here's what i changed:
setup.py:
reason: cython's maze of #defs and #undefs
_http_parser.c, line 30742:
reason:
aiohttp/_http_parser.c(30744): error C2039: 'ob_refcnt': is not a member of '_object'websocket\reader_c.c line 18485:
reason:
aiohttp/_websocket/reader_c.c(18487): error C2039: 'ob_refcnt': is not a member of '_object'Dreamsorcerer commentedon Apr 2, 2025
Well, the warning is because it doesn't support free-threading. Fixing the warning is done by supporting free-threading, i.e. what this issue tracks.
I think multidict and frozenlist have free-threading now, and yarl I believe is ready to merge and release. That'll probably be all the dependencies sorted, then it's just aiohttp itself that needs a similar update, so seems like it's getting close now.
webknjaz commentedon Apr 2, 2025
Isn't there some optional DNS/speedup stuff on top of the mandatory deps?
Dreamsorcerer commentedon Apr 2, 2025
I would assume an optional dependency is not a blocker to us. Maybe pycares will need an update? But, people can use it without aiodns until that becomes supported.
ngoldbaum commentedon Apr 2, 2025
It looks like pycares uses CFFI, so that might require using our fork of CFFI to get that working. See python-cffi/cffi#143 (comment). I'll open an issue over at the pycares repo.
9 remaining items
Dreamsorcerer commentedon Jul 17, 2025
You're running a much older version of pytest.
This one looks weird. How can it be a closed file when we're attempting to open it?
ngoldbaum commentedon Jul 17, 2025
Thanks! This is because of the hacked-together, manually constructed environment.
On a second look, I agree. Maybe there's something tricky going on in the pathlib implementation along the lines of python/cpython#136248, which seems similar. I'll try to reproduce this outside of aiohttp.
ngoldbaum commentedon Jul 23, 2025
I just re-did this exercise with a Python 3.14t interpreter. This required even more hacking of test dependencies, since a few of the dependencies in the test requirements file are pinned to versions that don't support 3.14.
With 3.14t, I no longer see the pathlib error I saw before. It's possible the fix for the issue I saw has been fixed in CPython
mainfor a while and the fix was never backported to 3.13 - I'll try to pin that down so we can make sure there's a backport.With 3.14t I see the following test failures and errors in the aiohttp tests:
I think these are probably all 3.14 compatibility issues? I would need to look closer.
Dreamsorcerer commentedon Jul 24, 2025
Possibly. With 3.14 in the release candidate stage, we should be able to start preparing 3.14 releases now.
Dreamsorcerer commentedon Jul 24, 2025
I've added 3.14 back to the testing matrix. Looks like initial blockers are isal and pydantic-core. I think pydantic is already resolved, but Dependabot seems to think it's not upgradeable, so may need a manual version bump.
ngoldbaum commentedon Jul 24, 2025
When I tried yesterday the incompatible constraint on pydantic-core was coming in from
python-on-whaleskumaraditya303 commentedon Jul 26, 2025
I have updated my PR at #10872 to avoid installing isal and python-on-whales on 3.14 as they are test are only dependencies and skipped tests if not present, with that most tests are now passing except one in cookie jar which was changed in 3.14.
I think this is a good starting point to merge that than waiting for all such non-required dependencies to ship 3.14 wheels.
cc @Dreamsorcerer
kumaraditya303 commentedon Jul 26, 2025
The incompaible constraint comes from pydantic which is a dependency of python-on-whales, see https://github.com/pydantic/pydantic/blob/5f033e46c54fea1b59b6894d6527daf49475e690/pyproject.toml#L49
Dreamsorcerer commentedon Jul 26, 2025
Looks like Pydantic should have a release in a few days, so we can wait that one out. If isal doesn't respond, then we'll have to consider your workarounds.
Dreamsorcerer commentedon Jul 26, 2025
In the meantime, we can use your branch to test any fixes needed for 3.14 and merge those fixes in separately.
Dreamsorcerer commentedon Jul 26, 2025
The failing test is unusual. My best guess is that Python 3.14 has changed how equality works, which seems like quite a surprising change...
kumaraditya303 commentedon Oct 7, 2025
aiohttpversion 3.13 is released with free-threading support, this is complete now.Dreamsorcerer commentedon Oct 7, 2025
Yes, thanks. I think we're only testing and officially supporting Python 3.14+.
[-]Support free-threaded Python 3.13 build[/-][+]Support free-threaded Python build[/+]