From 5fef842d42c773f76f3e64e0951cee985b3ff50c Mon Sep 17 00:00:00 2001 From: kana44 <171931708+kana44@users.noreply.github.com> Date: Mon, 29 Dec 2025 00:55:33 +0100 Subject: [PATCH] Add timeout best practices to documentation This pull request adds a short section about timeout best practices to the documentation. It helps beginners understand why timeouts are important and how to use them correctly. --- docs/user/advanced.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/user/advanced.rst b/docs/user/advanced.rst index 2ff0c7dfbf..7b4bea94f3 100644 --- a/docs/user/advanced.rst +++ b/docs/user/advanced.rst @@ -1136,3 +1136,18 @@ coffee. .. _`wall clock`: https://wiki.php.net/rfc/max_execution_wall_time .. _`connect()`: https://linux.die.net/man/2/connect + +Timeout Best Practices +--------------------- + +Using timeouts helps prevent requests from hanging indefinitely. +It is generally recommended to specify a timeout value for production code. + +For example:: + + requests.get('https://example.com', timeout=5) + +Note: A timeout value does not limit the total time of the request. It applies to +the connect and read operations (see the section above). + +This can improve application reliability and make error handling more predictable.