Skip to content

Commit addd57e

Browse files
authored
Merge pull request #457 from UiPath/fix/runtime-async-func
fix: core runtime await async functions
2 parents 692920a + 4c40cbd commit addd57e

3 files changed

Lines changed: 18 additions & 7 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "uipath"
3-
version = "2.0.79"
3+
version = "2.0.80"
44
description = "Python SDK and CLI for UiPath Platform, enabling programmatic interaction with automation services, process management, and deployment tools."
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.10"

src/uipath/_cli/_runtime/_runtime.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ async def execute(self) -> Optional[UiPathRuntimeResult]:
5050
if self.context.entrypoint is None:
5151
return None
5252

53-
script_result = self._execute_python_script(
53+
script_result = await self._execute_python_script(
5454
self.context.entrypoint, self.context.input_json
5555
)
5656

@@ -111,7 +111,7 @@ async def cleanup(self) -> None:
111111
"""Cleanup runtime resources."""
112112
pass
113113

114-
def _execute_python_script(self, script_path: str, input_data: Any) -> Any:
114+
async def _execute_python_script(self, script_path: str, input_data: Any) -> Any:
115115
"""Execute the Python script with the given input."""
116116
spec = importlib.util.spec_from_file_location("dynamic_module", script_path)
117117
if not spec or not spec.loader:
@@ -139,10 +139,13 @@ def _execute_python_script(self, script_path: str, input_data: Any) -> Any:
139139
sig = inspect.signature(main_func)
140140
params = list(sig.parameters.values())
141141

142+
# Check if the function is asynchronous
143+
is_async = inspect.iscoroutinefunction(main_func)
144+
142145
# Case 1: No parameters
143146
if not params:
144147
try:
145-
result = main_func()
148+
result = await main_func() if is_async else main_func()
146149
return (
147150
self._convert_from_class(result)
148151
if result is not None
@@ -166,7 +169,11 @@ def _execute_python_script(self, script_path: str, input_data: Any) -> Any:
166169
try:
167170
valid_type = cast(Type[Any], input_type)
168171
typed_input = self._convert_to_class(input_data, valid_type)
169-
result = main_func(typed_input)
172+
result = (
173+
await main_func(typed_input)
174+
if is_async
175+
else main_func(typed_input)
176+
)
170177
return (
171178
self._convert_from_class(result)
172179
if result is not None
@@ -183,7 +190,11 @@ def _execute_python_script(self, script_path: str, input_data: Any) -> Any:
183190
# Case 3: Dict parameter
184191
else:
185192
try:
186-
result = main_func(input_data)
193+
result = (
194+
await main_func(input_data)
195+
if is_async
196+
else main_func(input_data)
197+
)
187198
return (
188199
self._convert_from_class(result)
189200
if result is not None

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)