mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-15 14:03:02 +00:00
Merge pull request #1272 from yuvipanda/exponential-function
Move exponential backoff into a function
This commit is contained in:
@@ -20,7 +20,7 @@ from .. import __version__
|
||||
from .. import orm
|
||||
from ..objects import Server
|
||||
from ..spawner import LocalProcessSpawner
|
||||
from ..utils import url_path_join, DT_SCALE
|
||||
from ..utils import url_path_join, exponential_backoff
|
||||
|
||||
# pattern for the authentication token header
|
||||
auth_header_pat = re.compile(r'^(?:token|bearer)\s+([^\s]+)$', flags=re.IGNORECASE)
|
||||
@@ -641,7 +641,8 @@ class UserSpawnHandler(BaseHandler):
|
||||
# record redirect count in query parameter
|
||||
if redirects:
|
||||
self.log.warning("Redirect loop detected on %s", self.request.uri)
|
||||
yield gen.sleep(min(1 * (DT_SCALE ** redirects), 10))
|
||||
# add capped exponential backoff where cap is 10s
|
||||
yield gen.sleep(min(1 * (2 ** redirects), 10))
|
||||
# rewrite target url with new `redirects` query value
|
||||
url_parts = urlparse(target)
|
||||
query_parts = parse_qs(url_parts.query)
|
||||
|
Reference in New Issue
Block a user