Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions easybuild/tools/module_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -783,10 +783,12 @@ def load_module(self, mod_name, recursive_unload=False, unload_modules=None):
body.append(self.LOAD_TEMPLATE)

if build_option('recursive_mod_unload') or recursive_unload:
# not wrapping the 'module load' with an is-loaded guard ensures recursive unloading;
# when "module unload" is called on the module in which the depedency "module load" is present,
# it will get translated to "module unload"
load_statement = body + ['']
# wrapping the 'module load' with an 'is-loaded or mode == unload'
# guard ensures recursive unloading while avoiding load storms,
# when "module unload" is called on the module in which the
# depedency "module load" is present, it will get translated
# to "module unload"
load_statement = [self.conditional_statement('isloaded("%(mod_name)s") or mode() == "unload"', '\n'.join(body), negative=True)]
else:
load_statement = [self.conditional_statement('isloaded("%(mod_name)s")', '\n'.join(body), negative=True)]
Copy link
Member

Choose a reason for hiding this comment

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

@akesandgren This is a bit too copy-pasta, let's change this too the below, and include a reference to http://lmod.readthedocs.io/en/latest/210_load_storms.html:

if build_option('recursive_mod_unload') or recursive_unload:
    # ...
    # see also http://lmod.readthedocs.io/en/latest/210_load_storms.html
    load_guard = isloaded("%(mod_name)s") or mode() == "unload"'
else:
    load_guard = 'isloaded("%(mod_name)s")'
load_statement = [self.conditional_statement(load_guard, '\n'.join(body), negative=True)]


Expand Down