Skip to content

Commit 0abc89a

Browse files
Merge pull request #45 from antgonza/add-QIITA_PORT
add QIITA_PORT
2 parents 0e546ed + 185e9f6 commit 0abc89a

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

qiita_client/qiita_client.py

+13-3
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,10 @@ def _heartbeat(qclient, url):
8888
# This error occurs when the Qiita server is not reachable. This
8989
# may occur when we are updating the server, and we don't want
9090
# the job to fail. In this case, we wait for 5 min and try again
91-
time.sleep(randint(MIN_TIME_SLEEP, MAX_TIME_SLEEP))
91+
stime = randint(MIN_TIME_SLEEP, MAX_TIME_SLEEP)
92+
logger.debug('retry _heartbeat() %d, %d, %s' % (
93+
retries, stime, url))
94+
time.sleep(stime)
9295
retries -= 1
9396
except QiitaClientError:
9497
# If we raised the error, we propagate it since it is a problem
@@ -261,7 +264,11 @@ def _request_oauth2(self, req, *args, **kwargs):
261264
except requests.ConnectionError:
262265
if retries <= 0:
263266
raise
264-
time.sleep(randint(MIN_TIME_SLEEP, MAX_TIME_SLEEP))
267+
stime = randint(MIN_TIME_SLEEP, MAX_TIME_SLEEP)
268+
logger.debug(
269+
'retry QiitaClient._request_oauth2() %d, %d' % (
270+
retries, stime))
271+
time.sleep(stime)
265272
retries -= 1
266273
if r.status_code == 400:
267274
try:
@@ -347,7 +354,10 @@ def _request_retry(self, req, url, **kwargs):
347354
return r.json()
348355
except ValueError:
349356
return None
350-
time.sleep(randint(MIN_TIME_SLEEP, MAX_TIME_SLEEP))
357+
stime = randint(MIN_TIME_SLEEP, MAX_TIME_SLEEP)
358+
logger.debug('retry QiitaClient._request_retry() %d, %d, %s' % (
359+
retries, stime, url))
360+
time.sleep(stime)
351361

352362
raise RuntimeError(
353363
"Request '%s %s' did not succeed. Status code: %d. Message: %s"

qiita_client/testing.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ def setUpClass(cls):
2525
cls.client_secret = ('J7FfQ7CQdOxuKhQAf1eoGgBAE81Ns8Gu3EKaWFm3IO2JKh'
2626
'AmmCWZuabe0O5Mp28s1')
2727
cls.server_cert = environ.get('QIITA_SERVER_CERT', None)
28-
cls.qclient = QiitaClient("https://localhost:21174", cls.client_id,
29-
cls.client_secret,
30-
server_cert=cls.server_cert)
28+
qiita_port = int(environ.get('QIITA_PORT', 21174))
29+
cls.qclient = QiitaClient(
30+
"https://localhost:%d" % qiita_port, cls.client_id,
31+
cls.client_secret, server_cert=cls.server_cert)
3132
logger.debug(
3233
'PluginTestCase.setUpClass() token %s' % cls.qclient._token)
3334
cls.qclient.post('/apitest/reload_plugins/')

0 commit comments

Comments
 (0)