Skip to content

Conversation

@mirthebeijers
Copy link

Summary

Hi, this is my first contribution!!! Please be a little gentle with me ;-)

This is based on #3664 but I add fixes for

  • in the test suite deprecations are marked as fatal, and uvicorn is used to set up the tests, and uvicorn generates a deprecation warning because of iscoroutinefunction()
  • uvicorn is about to create a new release with a fix: Support Python 3.14 Kludex/uvicorn#2723 👀Python 3.14 has stricter requirements for event loops in background threads. The original code in httpx called server.run() which internally uses asyncio.run(), but this doesn't work properly in background threads in Python 3.14.
  • asyncio.get_event_loop() deprecated: The TestServer.serve() method was using asyncio.get_event_loop() which is now more restrictive in Python 3.14.

I'm not fully sure if this also passes on 3.9, it might need a little more work, but on 3.14 I think this fixes the problems ;-)

Copy link
Contributor

@cclauss cclauss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://pypi.org/project/uvicorn is currently 0.38.0

# See: https://github.com/agronholm/anyio/issues/508
"ignore: trio.MultiError is deprecated since Trio 0.22.0:trio.TrioDeprecationWarning"
"ignore: trio.MultiError is deprecated since Trio 0.22.0:trio.TrioDeprecationWarning",
# Python 3.14 deprecates asyncio.iscoroutinefunction, but uvicorn 0.35.0 still uses it
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://pypi.org/project/uvicorn is currently 0.38.0

@apteryks
Copy link

I can't apply this https://github.com/encode/httpx/pull/3693.patch cleanly to either 0.28 or the master branch. This is for commit def4778:

source is at 'python-httpx-0.28.1-checkout'
applying '/gnu/store/axdb3iyc1gg49my2lfgdx4mgaglkzg6b-python-httpx-python-3.14.patch'...
patching file httpx/concurrency/asyncio/__init__.py
Cannot rename file without two valid file names
9 out of 9 hunks ignored
patching file httpx/concurrency/asyncio/compat.py
can't find file to patch at input line 326
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/tests/test_concurrency.py b/tests/test_concurrency.py
|index ab93b30282..03f8c0aaea 100644
|--- a/tests/test_concurrency.py
|+++ b/tests/test_concurrency.py
--------------------------
No file to patch.  Skipping patch.
1 out of 1 hunk ignored
can't find file to patch at input line 355
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|
|From 1d2e5251e2b327e3da3926af57d22a7aad7982d3 Mon Sep 17 00:00:00 2001
|From: Jamie Hewland <[email protected]>
|Date: Sat, 21 Sep 2019 21:09:01 +0200
|Subject: [PATCH 2/3] Clean up imports
|
|---
| httpx/concurrency/asyncio/backend.py | 5 +++--
| httpx/concurrency/asyncio/compat.py  | 1 -
| 2 files changed, 3 insertions(+), 3 deletions(-)
|
|diff --git a/httpx/concurrency/asyncio/backend.py b/httpx/concurrency/asyncio/backend.py
|index 84f4dd62d5..ddac291b13 100644
|--- a/httpx/concurrency/asyncio/backend.py
|+++ b/httpx/concurrency/asyncio/backend.py
--------------------------
No file to patch.  Skipping patch.
1 out of 1 hunk ignored
patching file httpx/concurrency/asyncio/compat.py
can't find file to patch at input line 393
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|
|From d629af9d6ca13736c176c0c048bda5b3d06e5fd2 Mon Sep 17 00:00:00 2001
|From: Jamie Hewland <[email protected]>
|Date: Sat, 21 Sep 2019 21:45:28 +0200
|Subject: [PATCH 3/3] Give up on await-ing on the stream closing (for now)
|
|---
| httpx/concurrency/asyncio/backend.py | 4 +++-
| 1 file changed, 3 insertions(+), 1 deletion(-)
|
|diff --git a/httpx/concurrency/asyncio/backend.py b/httpx/concurrency/asyncio/backend.py
|index ddac291b13..607da37fba 100644
|--- a/httpx/concurrency/asyncio/backend.py
|+++ b/httpx/concurrency/asyncio/backend.py
--------------------------
No file to patch.  Skipping patch.
1 out of 1 hunk ignored

As seen trying to apply the patch to the Guix package, which uses patch with arguments "--force" "--no-backup-if-mismatch" "-p1" "--input" "/gnu/store/axdb3iyc1gg49my2lfgdx4mgaglkzg6b-python-httpx-python-3.14.patch to apply it.

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.

4 participants