diff --git a/pyproject.toml b/pyproject.toml index a8a6bae..5b525c3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "uipath-runtime" -version = "0.0.23" +version = "0.1.0" description = "Runtime abstractions and interfaces for building agents and automation scripts in the UiPath ecosystem" readme = { file = "README.md", content-type = "text/markdown" } requires-python = ">=3.11" diff --git a/src/uipath/runtime/debug/bridge.py b/src/uipath/runtime/debug/bridge.py index 2fe3307..7792061 100644 --- a/src/uipath/runtime/debug/bridge.py +++ b/src/uipath/runtime/debug/bridge.py @@ -55,6 +55,10 @@ async def wait_for_resume(self) -> Any: """Wait for resume command from debugger.""" ... + async def wait_for_terminate(self) -> None: + """Wait until the user has requested to terminate debugging.""" + ... + def get_breakpoints(self) -> list[str] | Literal["*"]: """Get nodes to suspend execution at. diff --git a/src/uipath/runtime/debug/runtime.py b/src/uipath/runtime/debug/runtime.py index ecb4b74..efd797e 100644 --- a/src/uipath/runtime/debug/runtime.py +++ b/src/uipath/runtime/debug/runtime.py @@ -251,36 +251,32 @@ async def _poll_trigger( while True: attempt += 1 - await self.debug_bridge.emit_state_update( - UiPathRuntimeStateEvent( - node_name="", - payload={ - "status": "polling", - "attempt": attempt, - }, - ) - ) - try: resume_data = await reader.read_trigger(trigger) if resume_data is not None: return resume_data + await self.debug_bridge.emit_state_update( + UiPathRuntimeStateEvent( + node_name="", + payload={ + "attempt": attempt, + }, + ) + ) + await self._wait_with_quit_check() except UiPathDebugQuitError: - logger.info("Quit requested during polling") raise except Exception as e: - logger.error(f"Error polling trigger: {e}", exc_info=True) await self.debug_bridge.emit_state_update( UiPathRuntimeStateEvent( node_name="", payload={ - "status": "poll_error", "attempt": attempt, - "error": str(e), + "info": str(e), }, ) ) @@ -294,10 +290,11 @@ async def _wait_with_quit_check(self) -> None: UiPathDebugQuitError: If quit is requested during wait """ sleep_task = asyncio.create_task(asyncio.sleep(self.trigger_poll_interval)) - resume_task = asyncio.create_task(self.debug_bridge.wait_for_resume()) + term_task = asyncio.create_task(self.debug_bridge.wait_for_terminate()) done, pending = await asyncio.wait( - {sleep_task, resume_task}, return_when=asyncio.FIRST_COMPLETED + {sleep_task, term_task}, + return_when=asyncio.FIRST_COMPLETED, ) for task in pending: @@ -305,14 +302,7 @@ async def _wait_with_quit_check(self) -> None: try: await task except asyncio.CancelledError: - # Expected when cancelling pending tasks; safe to ignore. pass - # Check if quit was triggered - if resume_task in done: - try: - await ( - resume_task - ) # This will raise UiPathDebugQuitError if it was a quit - except UiPathDebugQuitError: - raise + if term_task in done: + raise UiPathDebugQuitError("Debugging terminated during polling.") diff --git a/uv.lock b/uv.lock index 5fd19ed..c986c44 100644 --- a/uv.lock +++ b/uv.lock @@ -938,7 +938,7 @@ wheels = [ [[package]] name = "uipath-runtime" -version = "0.0.23" +version = "0.1.0" source = { editable = "." } dependencies = [ { name = "uipath-core" },