Skip to content

Utils: add an helper to increase opened file soft limit#4613

Open
maxenceprog wants to merge 1 commit into
mainfrom
4608-provide-a-helper-to-set-the-limit-number-of-opened-file-to-the-maximum
Open

Utils: add an helper to increase opened file soft limit#4613
maxenceprog wants to merge 1 commit into
mainfrom
4608-provide-a-helper-to-set-the-limit-number-of-opened-file-to-the-maximum

Conversation

@maxenceprog

Copy link
Copy Markdown
  • create a new module in silx.utils
  • call the new function in silx.app.view.main

close #4608

PR summary

AI Disclosure

  • No AI used
  • AI tool(s) ... used for ...

- create a new module in silx.utils
- call the new function in silx.app.view.main
# THE SOFTWARE.
#
# ###########################################################################*/
"""Utils function relative to system limit"""

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, i miss of imagination here

_logger = logging.getLogger()


def increase_max_opened_files():

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you think about that name ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

increase_opened_files_limit ? 🤷

@t20100 t20100 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO best to avoid lazy import while at it

Comment thread src/silx/app/view/main.py
Comment on lines -134 to +125
from silx.gui import qt

# Make sure matplotlib is configured
import silx.gui.utils.matplotlib # noqa
from silx.gui import qt

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no reason to change import order in this PR

@@ -0,0 +1,49 @@
# /*##########################################################################
#
# Copyright (c) 2019 European Synchrotron Radiation Facility

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If set best to use the right date:

Suggested change
# Copyright (c) 2019 European Synchrotron Radiation Facility
# Copyright (c) 2026 European Synchrotron Radiation Facility

_logger = logging.getLogger()


def increase_max_opened_files():

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

increase_opened_files_limit ? 🤷

Comment on lines +37 to +42
try:
import resource
except ImportError:
_logger.debug("No resource module available")
else:
if hasattr(resource, "RLIMIT_NOFILE"):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about putting import at the top of the file to avoid lazy loading:

try:
    import resource
except ImportError:
    resource = None

and use this here:

Suggested change
try:
import resource
except ImportError:
_logger.debug("No resource module available")
else:
if hasattr(resource, "RLIMIT_NOFILE"):
if resource is None:
_logger.debug("No resource module available")
return
if hasattr(resource, "RLIMIT_NOFILE"):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide a helper to set the limit number of opened file to the maximum

2 participants