set requests-get timeout to fail quickly when a server is unresponsive

This commit is contained in:
Kyle Mahan 2016-06-05 00:10:58 +00:00
parent 71be267613
commit 86e72edfc1
5 changed files with 7 additions and 3 deletions

View file

@ -27,7 +27,7 @@ pyquerystring==1.0.2
pytz==2016.4 pytz==2016.4
redis==2.10.5 redis==2.10.5
requests==2.10.0 requests==2.10.0
rq==0.6.0 rq==0.5.6
sgmllib3k==1.0.0 sgmllib3k==1.0.0
six==1.10.0 six==1.10.0
SQLAlchemy==1.0.13 SQLAlchemy==1.0.13

View file

@ -13,5 +13,5 @@ module=woodwind.wsgi
import=timers import=timers
#attach-daemon=venv/bin/rqworker high #attach-daemon=venv/bin/rqworker high
attach-daemon=venv/bin/rqworker high low
attach-daemon=venv/bin/python -m woodwind.websocket_server attach-daemon=venv/bin/python -m woodwind.websocket_server
attach-daemon=venv/bin/rqworker high low

View file

@ -85,6 +85,7 @@
{{ entry.published | relative_time }} {{ entry.published | relative_time }}
</time> </time>
</a> </a>
<a href="{{ url_for('.index', entry=entry.permalink) }}" target="_blank"> <a href="{{ url_for('.index', entry=entry.permalink) }}" target="_blank">
<i class="fa fa-external-link"></i> <i class="fa fa-external-link"></i>
</a> </a>

View file

@ -40,6 +40,9 @@ def requests_get(url, **kwargs):
if 'Last-Modified' in lastresp.headers: if 'Last-Modified' in lastresp.headers:
headers['If-Modified-Since'] = lastresp.headers['Last-Modified'] headers['If-Modified-Since'] = lastresp.headers['Last-Modified']
if 'timeout' not in kwargs:
kwargs['timeout'] = (9.1, 30)
current_app.logger.debug('fetching %s with args %s', url, kwargs) current_app.logger.debug('fetching %s with args %s', url, kwargs)
resp = requests.get(url, **kwargs) resp = requests.get(url, **kwargs)

View file

@ -355,7 +355,7 @@ def update_micropub_syndicate_to():
resp, resp.text) resp, resp.text)
return return
flask.current_app.logger.debug('syndicate-to response: {}, {}', flask.current_app.logger.debug('syndicate-to response: %s %s',
resp, resp.text) resp, resp.text)
content_type = resp.headers['content-type'] content_type = resp.headers['content-type']