Created
February 14, 2017 23:33
-
-
Save floatingatoll/18e82ff3db50e700c671214dba9f9333 to your computer and use it in GitHub Desktop.
socket timeout for feedparser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- feedparser-5.2.1/feedparser/feedparser.py 2015-07-23 22:00:04.000000000 -0700 | |
+++ feedparser.py.new 2017-02-14 15:31:11.000000000 -0800 | |
@@ -2910,7 +2910,10 @@ | |
return url | |
def _build_urllib2_request(url, agent, etag, modified, referrer, auth, request_headers): | |
+ _save_socket_timeout = socket.getdefaulttimeout() | |
+ socket.setdefaulttimeout(2.0) | |
request = urllib2.Request(url) | |
+ socket.setdefaulttimeout(_save_socket_timeout) | |
request.add_header('User-Agent', agent) | |
if etag: | |
request.add_header('If-None-Match', etag) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment