Skip to content

Commit d80cde1

Browse files
committed
Do not defer import if module is already imported
1 parent 4f1b93c commit d80cde1

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Diff for: pyomo/common/dependencies.py

+9
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,15 @@ def attempt_import(
676676
assert defer_import is None
677677
defer_import = defer_check
678678

679+
# If the module has already been imported, there is no reason to
680+
# further defer things: just import it.
681+
if defer_import is None:
682+
if name in sys.modules:
683+
defer_import = False
684+
deferred_submodules = None
685+
else:
686+
defer_import = True
687+
679688
# If we are going to defer the check until later, return the
680689
# deferred import module object
681690
if defer_import:

0 commit comments

Comments
 (0)