---
title: "Comment by Mike Dabydeen on \"Why requests.get(timeout=5) can still hang, and how to set a total deadline\" | Hashnode"
description: "Subclassing requests.exceptions.Timeout keeps the old handlers working, and that includes retry wrappers. A tenacity or backoff decorator set to retry on Timeou"
url: "https://hashnode.com/posts/why-requests-get-timeout-5-can-still-hang-and-how-to-set-a-total-deadline/6ade99556123af80316ccc42/comment/6adf36ffb03fc607cd39a1a4"
---

[Discussion](https://hashnode.com/posts/why-requests-get-timeout-5-can-still-hang-and-how-to-set-a-total-deadline/6ade99556123af80316ccc42)

Comment [Why requests.get(timeout=5) can still hang, and how to set a total deadline](https://hashnode.com/posts/why-requests-get-timeout-5-can-still-hang-and-how-to-set-a-total-deadline/6ade99556123af80316ccc42)

[Mike Dabydeen](https://hashnode.com/@firelinks)

[Oct 26](https://hashnode.com/posts/why-requests-get-timeout-5-can-still-hang-and-how-to-set-a-total-deadline/6ade99556123af80316ccc42/comment/6adf36ffb03fc607cd39a1a4)

Subclassing requests.exceptions.Timeout keeps the old handlers working, and that includes retry wrappers. A tenacity or backoff decorator set to retry on Timeout will now retry a DeadlineExceeded as well, so get\_json with deadline\_s=4 and three attempts can hold the caller for 12 seconds plus backoff, past the 10 second endpoint budget in your example.

I'd compute the deadline once, before the retry loop, and give each attempt only the time left. The attempts then share one budget instead of each getting a fresh four seconds.

[Parsa Mohammadi](https://hashnode.com/@tomosu)

[Oct 26](https://hashnode.com/posts/why-requests-get-timeout-5-can-still-hang-and-how-to-set-a-total-deadline/6ade99556123af80316ccc42/comment/6adf36ffb03fc607cd39a1a4#reply-6adf400a336ac1971c45134f)

good catch, and it bites hardest when the upstream is already slow, since the retries pile onto the struggling dependency.
