1
- "timeout" parameter is recommended in order to stop waiting for a call after a given number with the timeout parameter.
2
-
3
- See the following requests_timeouts _ documentation:
4
-
5
- - *Nearly all production code should use this parameter in nearly all requests. Failure to do so can cause your program to hang indefinitely *
6
-
7
- You can reproduce the issue using deelay.me
8
-
9
- .. code :: python
10
-
11
- import requests
12
- response = requests.get(" https://deelay.me/5000/http://localhost:80" ) # It will spend 5s
13
-
14
- response = requests.get(" https://deelay.me/5000/http://localhost:80" , timeout = 2 ) # timeout
15
-
16
- response = requests.get(" https://deelay.me/1000/http://localhost:80" , timeout = 2 ) # fine
17
-
18
-
19
- Now try to use a bigger delay value as ``https://deelay.me/1000000 ``
20
-
21
-
22
- Predefined Methods With Timeout
23
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24
- Pylint provides set of predefined method with timeout. Those predefined
25
- methods may be changed to add new ones from Pylint configuration.
26
-
27
- Following predefined methods are available:
1
+ You can add new methods that should have a defined ```timeout `` argument as qualified names
2
+ in the ``timeout-methods `` options, for example:
28
3
29
4
* ``requests.api.get ``
30
5
* ``requests.api.head ``
@@ -33,32 +8,3 @@ Following predefined methods are available:
33
8
* ``requests.api.post ``
34
9
* ``requests.api.put ``
35
10
* ``requests.api.request ``
36
-
37
- Following option is exposed:
38
-
39
- .. option :: --timeout-methods= <library.method >
40
-
41
-
42
- You can add new methods in your Pylint configuration
43
- using the pylint ``qname `` of the method
44
-
45
- You can get it using the following code:
46
-
47
- .. code :: python
48
-
49
- from astroid import extract_node
50
- node = extract_node(' from requests import get;get()' )
51
- print (next (node.func.infer()).qname())
52
-
53
- And the library needs to be installed in order to be detected
54
-
55
- You can add the following possible cases ``timeout-methods ``:
56
-
57
- * ``http.client.HTTPConnection ``
58
- * ``http.client.HTTPSConnection ``
59
- * ``serial.serialcli.Serial ``
60
- * ``smtplib.SMTP ``
61
- * ``suds.client.Client ``
62
- * ``urllib.request.urlopen ``
63
-
64
- .. _requests_timeouts : https://requests.readthedocs.io/en/latest/user/quickstart/#timeouts
0 commit comments