Page MenuHomePhabricator

requests version on labs fails with (x,y) timeout argument
Closed, ResolvedPublic

Description

This happens both on precise and trusty.

ERROR: Traceback (most recent call last):
  File "/home/valhallasw/src/pywikibot-core/pywikibot/data/api.py", line 1699, in submit
    body=body, headers=headers)
  File "/home/valhallasw/src/pywikibot-core/pywikibot/tools/__init__.py", line 1186, in wrapper
    return obj(*__args, **__kw)
  File "/home/valhallasw/src/pywikibot-core/pywikibot/comms/http.py", line 238, in request
    r = fetch(baseuri, method, body, headers, **kwargs)
  File "/home/valhallasw/src/pywikibot-core/pywikibot/comms/http.py", line 350, in fetch
    request = _enqueue(uri, method, body, headers, **kwargs)
  File "/home/valhallasw/src/pywikibot-core/pywikibot/comms/http.py", line 332, in _enqueue
    _http_process(session, request)
  File "/home/valhallasw/src/pywikibot-core/pywikibot/comms/http.py", line 250, in _http_process
    verify=True, timeout=timeout)
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 357, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 460, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 305, in send
    timeout = TimeoutSauce(connect=timeout, read=timeout)
  File "/usr/lib/python2.7/dist-packages/urllib3/util.py", line 116, in __init__
    self._connect = self._validate_timeout(connect, 'connect')
  File "/usr/lib/python2.7/dist-packages/urllib3/util.py", line 147, in _validate_timeout
    "int or float." % (name, value))
ValueError: Timeout value connect was (30, 120), but it must be an int or float.

Event Timeline

valhallasw raised the priority of this task from to Needs Triage.
valhallasw updated the task description. (Show Details)
valhallasw added a project: Pywikibot.
valhallasw added a subscriber: valhallasw.

With d3678819 the requests' timeout parameter is used and by default using a tuple. And it appears that older versions of requests or urllib3 don't support that yet. So a quick fix would be to set the default timeout to just a int. The other question is whether requests or urllib3 add support for that and we need to add a version check accordingly and can then just use the lower of the two values and maybe inform the user.

Okay requests 2.4.0 adds support for multiple timeouts although it's unclear if that is because of urllib3. Looking into urllib3's documentation it does support complex timeouts but doesn't use a tuple for this so requests version 2.4.0 might still be needed to convert it into an urllib3 compatible type.

Change 219441 had a related patch set uploaded (by XZise):
[FIX] Use only a single timeout

https://gerrit.wikimedia.org/r/219441

Change 219441 merged by jenkins-bot:
[FIX] Use only a single timeout

https://gerrit.wikimedia.org/r/219441

jayvdb claimed this task.
XZise set Security to None.

There are several failures on https://travis-ci.org/jayvdb/pywikibot-core/builds/67500465 . Some of them we already know, like T101138 and maybe T91394 cropping up again. It would be good to know what other bugs there are in different versions.