From d333cc35f427d828a7a19aa46b891374a9f2a7dc Mon Sep 17 00:00:00 2001 From: MichaelYin Date: Wed, 9 Sep 2015 17:29:17 +0800 Subject: [PATCH 1/2] add timeout support to upwork.client --- upwork/client.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/upwork/client.py b/upwork/client.py index 46a18fa..3832965 100644 --- a/upwork/client.py +++ b/upwork/client.py @@ -89,13 +89,15 @@ class Client(object): Whether to attach :py:mod:`upwork.routers.job` router + :timeout: (optional, default ``60 secs``) + Socket operations timeout. """ def __init__(self, public_key, secret_key, oauth_access_token=None, oauth_access_token_secret=None, fmt='json', finreport=True, hr=True, mc=True, offers=True, provider=True, task=True, team=True, - timereport=True, job=True): + timereport=True, job=True, timeout=60): self.public_key = public_key self.secret_key = secret_key @@ -113,7 +115,9 @@ def __init__(self, public_key, secret_key, logging.captureWarnings(True) self.http = urllib3.PoolManager( cert_reqs='CERT_REQUIRED', - ca_certs=ca_certs_locater.get()) + ca_certs=ca_certs_locater.get(), + timeout=int(timeout) + ) self.oauth_access_token = oauth_access_token self.oauth_access_token_secret = oauth_access_token_secret From fbde3e142a153db05c9c86b354212ff44f4ea21d Mon Sep 17 00:00:00 2001 From: MichaelYin Date: Wed, 9 Sep 2015 21:58:46 +0800 Subject: [PATCH 2/2] change the timeout to lower value --- upwork/client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/upwork/client.py b/upwork/client.py index 3832965..c6f6e30 100644 --- a/upwork/client.py +++ b/upwork/client.py @@ -89,7 +89,7 @@ class Client(object): Whether to attach :py:mod:`upwork.routers.job` router - :timeout: (optional, default ``60 secs``) + :timeout: (optional, default ``3 secs``) Socket operations timeout. """ @@ -97,7 +97,7 @@ def __init__(self, public_key, secret_key, oauth_access_token=None, oauth_access_token_secret=None, fmt='json', finreport=True, hr=True, mc=True, offers=True, provider=True, task=True, team=True, - timereport=True, job=True, timeout=60): + timereport=True, job=True, timeout=3): self.public_key = public_key self.secret_key = secret_key