Handle asynchronous cancellations for HTTPConnection instances#802
Closed
karpetrosyan wants to merge 11 commits intoencode:masterfrom
Closed
Handle asynchronous cancellations for HTTPConnection instances#802karpetrosyan wants to merge 11 commits intoencode:masterfrom
karpetrosyan wants to merge 11 commits intoencode:masterfrom
Conversation
karpetrosyan
commented
Sep 14, 2023
| keepalive_expiry=self._keepalive_expiry, | ||
| ) | ||
| except Exception as exc: | ||
| except BaseException as exc: |
Contributor
Author
There was a problem hiding this comment.
This is to be sure that it works when we cancel the asynchronous task.
zanieb
reviewed
Sep 14, 2023
zanieb
reviewed
Sep 14, 2023
Co-authored-by: Zanie Blue <contact@zanie.dev>
Co-authored-by: Zanie Blue <contact@zanie.dev>
Contributor
Author
|
Alternatively, we can add states for HTTPConnection instances (NEW, CONNECTING, FAILED), but I believe we should avoid that because we already have connecting states in HTTP11Connection instances. |
|
This PR works well based on my testing. |
Contributor
Author
|
Now the connection has a state of connecting, even if it was just created and is not trying to connect somewhere. This pull request simply adds the new state for such connections. |
magentalabs-serviceagent-1
pushed a commit
to magenta-aps/ra-clients
that referenced
this pull request
Nov 22, 2023
We're experiencing timeout errors in various integrations, but it does not look like we ever send the request to OS2mo/Keycloak/etc. This MR bumps httpx to bump httpcore to 0.18.0 to include this fix: encode/httpcore#641. If we're lucky, that's it. Otherwise, we are probably waiting for this to be merged: encode/httpcore#802.
magentalabs-serviceagent-1
pushed a commit
to magenta-aps/ra-clients
that referenced
this pull request
Nov 22, 2023
We're experiencing timeout errors in various integrations, but it does not look like we ever send the request to OS2mo/Keycloak/etc. This MR bumps httpx to a patched version which in turn depends on patched version of httpcore which includes encode/httpcore#802, which I suspect is our issue. Another related issue has also been fixed (encode/httpcore#641), and is already included in httpcore 0.18.0.
Contributor
|
Now #785 closed, I think you can close this PR too. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivated by encode/httpx#947 🔥
Closes #785
This pull request just adds some logic to check if the connection was previously used or if it's just been created.
Now the example from #785 works fine(?).
It's very hard to explain where the problem actually is, but I think you can find the answer to that question in #785.
In simple words, the client always thinks that there cannot be a connection that has not failed and is also not in the connecting process. This is because every connection is attached to some request when it's created, and there are no cases when it can just hang in our connection pool except for asynchronous cancellations.
Now the
HTTPConnectioninstances can be new if "._is_new" is set to true and failed if "._connect_failed" is set to true. Otherwise, if both of them are false, that means it's in the connecting process.