equal
deleted
inserted
replaced
40 # |
40 # |
41 # We wait `retry.interval` between each retry, in seconds. |
41 # We wait `retry.interval` between each retry, in seconds. |
42 # (default 1 second). |
42 # (default 1 second). |
43 retry = 3 |
43 retry = 3 |
44 retry.interval = 10 |
44 retry.interval = 10 |
|
45 |
|
46 # the retry option can combine well with the http.timeout one. |
|
47 # |
|
48 # For example to give up on http request after 20 seconds: |
|
49 [http] |
|
50 timeout=20 |
45 |
51 |
46 [auth] |
52 [auth] |
47 example.schemes = https |
53 example.schemes = https |
48 example.prefix = phab.example.com |
54 example.prefix = phab.example.com |
49 |
55 |
418 body = sout.read() |
424 body = sout.read() |
419 else: |
425 else: |
420 urlopener = urlmod.opener(ui, authinfo) |
426 urlopener = urlmod.opener(ui, authinfo) |
421 request = util.urlreq.request(pycompat.strurl(url), data=data) |
427 request = util.urlreq.request(pycompat.strurl(url), data=data) |
422 max_try = ui.configint(b'phabricator', b'retry') + 1 |
428 max_try = ui.configint(b'phabricator', b'retry') + 1 |
|
429 timeout = ui.configwith(float, b'http', b'timeout') |
423 for try_count in range(max_try): |
430 for try_count in range(max_try): |
424 try: |
431 try: |
425 with contextlib.closing(urlopener.open(request)) as rsp: |
432 with contextlib.closing( |
|
433 urlopener.open(request, timeout=timeout) |
|
434 ) as rsp: |
426 body = rsp.read() |
435 body = rsp.read() |
427 break |
436 break |
428 except util.urlerr.urlerror as err: |
437 except util.urlerr.urlerror as err: |
429 if try_count == max_try - 1: |
438 if try_count == max_try - 1: |
430 raise |
439 raise |