Skip to content

Commit 5e725f4

Browse files
committed
docs: add timeout handling example to quickstart guide
1 parent 74cb948 commit 5e725f4

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

docs/user/quickstart.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,13 @@ You can also specify **custom headers** while making a request, for example:
5959
print(response.status_code)
6060
print(response.json())
6161
62-
That's all well and good, but it's also only the start of what Requests can
63-
do.
62+
>>> import requests
63+
>>> try:
64+
... r = requests.get('https://httpbin.org/delay/3', timeout=2)
65+
... except requests.exceptions.Timeout:
66+
... print("The request timed out")
67+
... else:
68+
... print("Request completed successfully:", r.status_code)
6469

6570

6671
Passing Parameters In URLs

0 commit comments

Comments
 (0)