Skip to content

Commit

Permalink
Add timeout to requests calls (#200)
Browse files Browse the repository at this point in the history
  • Loading branch information
danmichaelo committed Nov 9, 2018
1 parent aecb4aa commit eddbdb2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mwclient/client.py
Expand Up @@ -63,6 +63,8 @@ def __init__(self, host, path='/w/', ext='.php', pool=None, retry_timeout=30,
self.max_lag = text_type(max_lag)
self.force_login = force_login
self.requests = reqs or {}
if 'timeout' not in self.requests:
self.requests['timeout'] = 30 # seconds

if consumer_token is not None:
auth = OAuth1(consumer_token, consumer_secret, access_token, access_secret)
Expand Down Expand Up @@ -373,7 +375,9 @@ def raw_call(self, script, data, files=None, retry_on_error=True, http_method='P

while True:
try:
args = {'files': files, 'headers': headers, **self.requests}
args = {'files': files, 'headers': headers}
for k, v in self.requests.items():
args[k] = v
if http_method == 'GET':
args['params'] = data
else:
Expand Down

0 comments on commit eddbdb2

Please sign in to comment.