Skip to content

Instantly share code, notes, and snippets.

@floatingatoll

floatingatoll/.patch

Created Feb 14, 2017
Embed
What would you like to do?
socket timeout for feedparser
--- 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