diff --git a/packages/robot/src/robotcode/robot/diagnostics/imports_manager.py b/packages/robot/src/robotcode/robot/diagnostics/imports_manager.py index 3c0607aa..83a45e89 100644 --- a/packages/robot/src/robotcode/robot/diagnostics/imports_manager.py +++ b/packages/robot/src/robotcode/robot/diagnostics/imports_manager.py @@ -96,8 +96,8 @@ REST_EXTENSIONS = (".rst", ".rest") -LOAD_LIBRARY_TIME_OUT = 10 -COMPLETE_LIBRARY_IMPORT_TIME_OUT = COMPLETE_RESOURCE_IMPORT_TIME_OUT = COMPLETE_VARIABLES_IMPORT_TIME_OUT = 5 +LOAD_LIBRARY_TIMEOUT: int = int(os.environ.get("ROBOTCODE_LOAD_LIBRARY_TIMEOUT", 10)) +COMPLETE_LIBRARY_IMPORT_TIMEOUT = COMPLETE_RESOURCE_IMPORT_TIMEOUT = COMPLETE_VARIABLES_IMPORT_TIMEOUT = 5 class _EntryKey: @@ -1266,10 +1266,15 @@ def _get_library_libdoc( base_dir, self.get_resolvable_command_line_variables(), variables, - ).result(LOAD_LIBRARY_TIME_OUT) + ).result(LOAD_LIBRARY_TIMEOUT) except TimeoutError as e: - raise RuntimeError(f"Timeout loading library {name}({args!r})") from e + raise RuntimeError( + f"""Exceeded timeout of {LOAD_LIBRARY_TIMEOUT} seconds loading library {name}({args!r}). + Check implementation of the library, why instantiation would take so long. If you think, + you require more time to load a library, set environment variable + ROBOTCODE_LOAD_LIBRARY_TIMEOUT to amount of seconds.""" + ) from e except (SystemExit, KeyboardInterrupt): raise @@ -1438,10 +1443,15 @@ def _get_variables_libdoc( base_dir, self.get_resolvable_command_line_variables() if resolve_command_line_vars else None, variables, - ).result(LOAD_LIBRARY_TIME_OUT) + ).result(LOAD_LIBRARY_TIMEOUT) except TimeoutError as e: - raise RuntimeError(f"Timeout loading library {name}({args!r})") from e + raise RuntimeError( + f"""Exceeded timeout of {LOAD_LIBRARY_TIMEOUT} seconds loading library {name}({args!r}). + Check implementation of the library, why instantiation would take so long. If you think, + you require more time to load a library, set environment variable + ROBOTCODE_LOAD_LIBRARY_TIMEOUT to amount of seconds.""" + ) from e except (SystemExit, KeyboardInterrupt): raise @@ -1608,7 +1618,7 @@ def complete_library_import( base_dir, self.get_resolvable_command_line_variables(), variables, - ).result(COMPLETE_LIBRARY_IMPORT_TIME_OUT) + ).result(COMPLETE_LIBRARY_IMPORT_TIMEOUT) def complete_resource_import( self, @@ -1623,7 +1633,7 @@ def complete_resource_import( base_dir, self.get_resolvable_command_line_variables(), variables, - ).result(COMPLETE_RESOURCE_IMPORT_TIME_OUT) + ).result(COMPLETE_RESOURCE_IMPORT_TIMEOUT) def complete_variables_import( self, @@ -1638,7 +1648,7 @@ def complete_variables_import( base_dir, self.get_resolvable_command_line_variables(), variables, - ).result(COMPLETE_VARIABLES_IMPORT_TIME_OUT) + ).result(COMPLETE_VARIABLES_IMPORT_TIMEOUT) def resolve_variable( self,