pastycake icon indicating copy to clipboard operation
pastycake copied to clipboard

HTTP Socket Failure

Open 9b opened this issue 13 years ago • 2 comments

When making an HTTP call, it appears that the socket used to initiate the remote connection is sometimes null therefore resulting in the following error. This error is usually discovered after the program has been running for some time and then just stops.

Traceback (most recent call last): File "gather.py", line 113, in <module> main() File "gather.py", line 102, in main sources, keywords, store_match=True) File "gather.py", line 55, in fetch status, data = generator.get_paste(path) File "/home/brandon/documents/tools/pastycake/pastycake/pastebin_source.py", line 22, in get_paste return http.request(url) File "/usr/lib/python2.7/dist-packages/httplib2/__init__.py", line 1129, in request (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey) File "/usr/lib/python2.7/dist-packages/httplib2/__init__.py", line 901, in _request (response, content) = self._conn_request(conn, request_uri, method, body, headers) File "/usr/lib/python2.7/dist-packages/httplib2/__init__.py", line 871, in _conn_request response = conn.getresponse() File "/usr/lib/python2.7/httplib.py", line 1025, in getresponse response = self.response_class(*args, **kwds) File "/usr/lib/python2.7/httplib.py", line 346, in __init__ self.fp = sock.makefile('rb', 0) AttributeError: 'NoneType' object has no attribute 'makefile'

9b avatar Feb 02 '12 14:02 9b

judging by a quick search, it seems to be an upstream regression [1,2,3] or a timeout/connectivity issue[4] will add a try/except and work around it.

[1] http://code.google.com/p/httplib2/issues/detail?id=96 [2] https://code.google.com/p/httplib2/issues/detail?id=101 [3] http://code.google.com/p/httplib2/issues/detail?id=102 [4] http://stackoverflow.com/a/4056552

coh2 avatar Feb 02 '12 21:02 coh2

also, I wonder if making the sleep time a bit random would help as the remote might wrongly assumes that a DoS is going on and tries to block some requests.

coh2 avatar Feb 02 '12 21:02 coh2