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

Fix breakage with aiohttp>=3.10.0 when using GCM and an HTTP proxy #395

Merged
merged 4 commits into from
Oct 2, 2024

Conversation

anoadragon453
Copy link
Member

@anoadragon453 anoadragon453 commented Oct 2, 2024

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.

We would do this when using GCM + an HTTP proxy:

sygnal/sygnal/gcmpushkin.py

Lines 213 to 217 in 345aa61

if proxy_url:
# `ClientSession` can't directly take the proxy URL, so we need to
# set the usual env var and use `trust_env=True`
os.environ["HTTPS_PROXY"] = proxy_url
session = aiohttp.ClientSession(trust_env=True, auto_decompress=False)

Rather than pin aiohttp to an older version, let's just fix the behaviour. Supersedes #394.

@anoadragon453 anoadragon453 requested a review from a team as a code owner October 2, 2024 09:44
@anoadragon453 anoadragon453 changed the title Only call aiohttp.ClientSession from async func Support aiohttp>=3.10.0 by calling aiohttp.ClientSession from an async function Oct 2, 2024
@anoadragon453 anoadragon453 changed the title Support aiohttp>=3.10.0 by calling aiohttp.ClientSession from an async function Fix breakage with aiohttp>=3.10.0 when using GCM and an HTTP proxy Oct 2, 2024
@anoadragon453 anoadragon453 force-pushed the anoa/aiohttp_client_session branch 2 times, most recently from 4667760 to 81ec6d3 Compare October 2, 2024 09:56
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.
sygnal/gcmpushkin.py Outdated Show resolved Hide resolved
@anoadragon453 anoadragon453 merged commit 92f555f into main Oct 2, 2024
5 checks passed
@anoadragon453 anoadragon453 deleted the anoa/aiohttp_client_session branch October 2, 2024 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants