Skip to content

Commit

Permalink
allowing users to specify request timeout in seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
heynemann committed Nov 16, 2013
1 parent 218eb4d commit 6cbef99
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions octopus/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@ def __init__(self, status_code, body, error=None):


class Octopus(object):
def __init__(self, concurrency=10, auto_start=False, cache=False, expiration_in_seconds=30):
def __init__(self, concurrency=10, auto_start=False, cache=False, expiration_in_seconds=30, request_timeout_in_seconds=5):
self.concurrency = concurrency
self.auto_start = auto_start

self.cache = cache
self.response_cache = Cache(expiration_in_seconds=expiration_in_seconds)
self.request_timeout_in_seconds = request_timeout_in_seconds

self.url_queue = OctopusQueue()

Expand Down Expand Up @@ -91,7 +92,7 @@ def do_work(self):

if response is None:
try:
response = requests.request(method, url, **kwargs)
response = requests.request(method, url, timeout=self.request_timeout_in_seconds, **kwargs)
except requests.ConnectionError:
err = sys.exc_info()[1]
response = ResponseError(
Expand Down

0 comments on commit 6cbef99

Please sign in to comment.