- Notifications
You must be signed in to change notification settings - Fork5.5k
Add reconnection to Gateway (form nb2kg)#5924
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes from2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
14 changes: 12 additions & 2 deletionsnotebook/gateway/handlers.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
37 changes: 34 additions & 3 deletionsnotebook/gateway/managers.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -15,14 +15,14 @@ | ||
| from jupyter_client.kernelspec import KernelSpecManager | ||
| from ..utils import url_path_join | ||
| from traitlets import Instance, Unicode,Int,Float, Bool, default, validate, TraitError | ||
| from traitlets.config import SingletonConfigurable | ||
| class GatewayClient(SingletonConfigurable): | ||
| """This class manages the configuration. It's its own singleton class so that we | ||
| can share these values across all objects. It also contains some helper methods | ||
| to build request arguments out of the various config options. | ||
| """ | ||
| @@ -220,6 +220,38 @@ def __init__(self, **kwargs): | ||
| def _env_whitelist_default(self): | ||
| return os.environ.get(self.env_whitelist_env, self.env_whitelist_default_value) | ||
| gateway_retry_interval_default_value = 1.0 | ||
| gateway_retry_interval_env = 'JUPYTER_GATEWAY_RETRY_INTERVAL' | ||
| gateway_retry_interval = Float(default_value=gateway_retry_interval_default_value, config=True, | ||
| help="""The time allowed for HTTP reconnection with the Gateway server for the first time. | ||
| Next will be JUPYTER_GATEWAY_RETRY_INTERVAL multiplied by two in factor of numbers of retries | ||
| but less than JUPYTER_GATEWAY_RETRY_INTERVAL_MAX. | ||
| (JUPYTER_GATEWAY_RETRY_INTERVAL env var)""") | ||
| @default('gateway_retry_interval') | ||
| def gateway_retry_interval_default(self): | ||
| return float(os.environ.get('JUPYTER_GATEWAY_RETRY_INTERVAL', self.gateway_retry_interval_default_value)) | ||
| gateway_retry_interval_max_default_value = 30.0 | ||
| gateway_retry_interval_max_env = 'JUPYTER_GATEWAY_RETRY_INTERVAL_MAX' | ||
| gateway_retry_interval_max = Float(default_value=gateway_retry_interval_max_default_value, config=True, | ||
| help="""The maximum time allowed for HTTP reconnection retry with the Gateway server. | ||
| (JUPYTER_GATEWAY_RETRY_INTERVAL_MAX env var)""") | ||
| @default('gateway_retry_interval_max') | ||
| def gateway_retry_interval_max_default(self): | ||
| return float(os.environ.get('JUPYTER_GATEWAY_RETRY_INTERVAL_MAX', self.gateway_retry_interval_max_default_value)) | ||
| gateway_retry_max_default_value = 5 | ||
| gateway_retry_max_env = 'JUPYTER_GATEWAY_RETRY_MAX' | ||
| gateway_retry_max = Int(default_value=gateway_retry_max_default_value, config=True, | ||
| help="""The maximum numbers allowed for HTTP reconnection retries with the Gateway server. | ||
oyvsyo marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| (JUPYTER_GATEWAY_RETRY_MAX env var)""") | ||
| @default('gateway_retry_max') | ||
| def gateway_retry_max_default(self): | ||
| return int(os.environ.get('JUPYTER_GATEWAY_RETRY_MAX', self.gateway_retry_max_default_value)) | ||
| @property | ||
| def gateway_enabled(self): | ||
| return bool(self.url is not None and len(self.url) > 0) | ||
| @@ -503,7 +535,6 @@ def shutdown_all(self, now=False): | ||
| self.remove_kernel(kernel_id) | ||
| class GatewayKernelSpecManager(KernelSpecManager): | ||
| def __init__(self, **kwargs): | ||
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.