Merge pull request #5075 from shevelevs/DynamicDefaultForMinOpenFilesLimit

Making default value for min_open_files_limit dynamic
This commit is contained in:
Thomas Kluyver 2019-11-24 19:02:39 +00:00 committed by GitHub
commit 10c7d2a53f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -817,7 +817,7 @@ class NotebookApp(JupyterApp):
"""
)
min_open_files_limit = Integer(4096, config=True,
min_open_files_limit = Integer(config=True,
help="""
Gets or sets a lower bound on the open file handles process resource
limit. This may need to be increased if you run into an
@ -825,6 +825,22 @@ class NotebookApp(JupyterApp):
This is not applicable when running on Windows.
""")
@default('min_open_files_limit')
def _default_min_open_files_limit(self):
if resource is None:
# Ignoring min_open_files_limit because the limit cannot be adjusted (for example, on Windows)
return None
soft, hard = resource.getrlimit(resource.RLIMIT_NOFILE)
DEFAULT_SOFT = 4096
if hard >= DEFAULT_SOFT:
return DEFAULT_SOFT
self.log.debug("Default value for min_open_files_limit is ignored (hard=%r, soft=%r)", hard, soft)
return soft
@observe('token')
def _token_changed(self, change):
self._token_generated = False