Skip to content

Fixed handling of exceptions, such as socket.timeout - #2

Merged
Anorov merged 1 commit into
Anorov:masterfrom
mdevaev:master
Dec 11, 2013
Merged

Anorov merged 1 commit into
Anorov:masterfrom
mdevaev:master

Conversation

@mdevaev

@mdevaev mdevaev commented Dec 11, 2013

Copy link
Copy Markdown
Contributor

Exceptions do not always have errno or msg, so we need to handle all possible cases.
Below, you can see an example of errors without fixing this:

...
            return opener.open(request, timeout=timeout).read()
          File "/usr/lib/python3.3/urllib/request.py", line 469, in open
            response = self._open(req, data)
          File "/usr/lib/python3.3/urllib/request.py", line 487, in _open
            '_open', req)
          File "/usr/lib/python3.3/urllib/request.py", line 447, in _call_chain
            result = func(*args)
          File "/usr/lib/python3.3/site-packages/ulib/network/url.py", line 76, in http_open
            return self.do_open(build, request)
          File "/usr/lib/python3.3/urllib/request.py", line 1248, in do_open                                                                                                
            h.request(req.get_method(), req.selector, req.data, headers)                                                                                                    
          File "/usr/lib/python3.3/http/client.py", line 1061, in request                                                                                                   
            self._send_request(method, url, body, headers)
          File "/usr/lib/python3.3/http/client.py", line 1099, in _send_request
            self.endheaders(body)
          File "/usr/lib/python3.3/http/client.py", line 1057, in endheaders
            self._send_output(message_body)
          File "/usr/lib/python3.3/http/client.py", line 902, in _send_output
            self.send(msg)
          File "/usr/lib/python3.3/http/client.py", line 840, in send
            self.connect()
          File "/usr/lib/python3.3/site-packages/ulib/network/url.py", line 65, in connect
            self.sock.connect((self.host, self.port))
          File "/usr/lib/python3.3/site-packages/socks.py", line 480, in connect
            errno, msg = error.args
        ValueError: need more than 1 value to unpack

…ot always have errno or msg, so we need to handle all possible cases.
Anorov added a commit that referenced this pull request Dec 11, 2013
Fixed handling of exceptions, such as socket.timeout
@Anorov
Anorov merged commit 5c9df12 into Anorov:master Dec 11, 2013
@Anorov

Anorov commented Dec 11, 2013

Copy link
Copy Markdown
Owner

Good catch. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants