Skip to content

Commit

Permalink
Merge pull request #5075 from shevelevs/DynamicDefaultForMinOpenFiles…
Browse files Browse the repository at this point in the history
…Limit

Making default value for min_open_files_limit dynamic
  • Loading branch information
takluyver committed Nov 24, 2019
2 parents 1efa780 + e46a344 commit 10c7d2a
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion notebook/notebookapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -817,14 +817,30 @@ def _token_default(self):
"""
)

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
OSError: [Errno 24] Too many open files.
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
Expand Down

0 comments on commit 10c7d2a

Please sign in to comment.