Skip to content

Conversation

@karpetrosyan
Copy link
Contributor

@karpetrosyan karpetrosyan commented Jul 13, 2024

Todo

  • Update documentation

Hi! It seems we have received many requests for adding total timeout support.

In each place where we are using the operation (read, write, pool, connect) timeout, we should take the minimum value of the operation timeout (timeouts['pool'], for example) and the total timeout value (timeouts['total']). We should also measure the time of each operation and adjust the value of the total timeout accordingly, so we always have the correct total timeout value within the scope of the request.

I'v used the context manager syntax to simplify time measuring, also have added a simple api level test for total timeout, as we don't have any tests for the concrete timeouts

@karpetrosyan
Copy link
Contributor Author

@tomchristie Any thoughts?

@lovelydinosaur
Copy link
Contributor

Thanks @karpetrosyan...

Any thoughts?

  • This is a fantastic piece of functionality to add yes, much needed.
  • Could we get a docs update.
  • Related work that's become apparent to me is that read/write timeouts are the wrong API... a single socket timeout would be a better fit.

@karpetrosyan
Copy link
Contributor Author

I guess that's all from our side. The remaining documentation will be available in the HTTPX docs.

@gsakkis
Copy link

gsakkis commented Aug 28, 2024

@karpetrosyan this looks great! Unfortunately this doesn't quit solve my use case as I want to exclude pool timeout from total. How hard would it be make the definition of total customizable? Potential API off the top of my head:

r = httpcore.request(
    "GET",
    "https://www.example.com",
    extensions={"timeout": {
        "read": 1.0, 
        ("connect", "read", "write"): 3.0,
        ("connect", "read", "write", "pool"): 10.0,  # equivalent to "total"
    }}
)

@brosoul
Copy link

brosoul commented Oct 16, 2024

I'm really looking forward to this feature. Could you please ping me after PR is ready?

@gsakkis
Copy link

gsakkis commented Oct 16, 2024

@brosoul there is a "subscribe" button at the top right of the page, click it to get notified for updates to this issue.

@lovelydinosaur
Copy link
Contributor

Thanks so much for your work on this @karpetrosyan.

I've been spending a little time thinking about this and I reckon there's a more fundamental improvement we could be making here. Design discussion over at #982.

@stale
Copy link

stale bot commented Jun 27, 2025

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Jun 27, 2025
@stale stale bot closed this Jul 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wontfix This will not be worked on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants