Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Commit

Permalink
Time out pycurl after 5 minutes
Browse files Browse the repository at this point in the history
  • Loading branch information
nlsun committed Sep 5, 2017
1 parent 6fc642d commit b6c75dc
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,18 @@ def __init__(self, url, auth, verify):
self.curl.setopt(pycurl.ENCODING, 'gzip')
self.curl.setopt(pycurl.CONNECTTIMEOUT, 10)
self.curl.setopt(pycurl.WRITEDATA, self.received_buffer)

# The below settings are to prevent the connection from hanging if the
# connection breaks silently. Since marathon-lb only listens, silent
# connection failure results in marathon-lb waiting infinitely.
#
# Minimum bytes/second below which it is considered "low speed". So
# "low speed" here refers to 0 bytes/second.
self.curl.setopt(pycurl.LOW_SPEED_LIMIT, 1)
# How long (in seconds) it's allowed to go below the speed limit
# before it times out
self.curl.setopt(pycurl.LOW_SPEED_TIME, 300)

if auth and type(auth) is DCOSAuth:
auth.refresh_auth_header()
headers.append('Authorization: %s' % auth.auth_header)
Expand Down

0 comments on commit b6c75dc

Please sign in to comment.