Skip to content
Merged
Changes from all commits
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
28 changes: 19 additions & 9 deletions packages/robot/src/robotcode/robot/diagnostics/imports_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
Loading