Skip to content

Automate browser based workflows with AI

⚡️ Speed up method `AsyncOperationPool._get_operation` by 10% (#1914)

Saurabh Misrabc9afaeb3c17
diff --git a/skyvern/forge/async_operations.py b/skyvern/forge/async_operations.py
index db825887e..f440c0ac1 100644
--- a/skyvern/forge/async_operations.py
+++ b/skyvern/forge/async_operations.py
@@ -83,7 +83,11 @@ class AsyncOperationPool:
self._add_operation(task_id, operation)
def _get_operation(self, task_id: str, agent_phase: AgentPhase) -> AsyncOperation | None:
- return self._operations.get(task_id, {}).get(agent_phase, None)
+ # Direct dictionary access and exception handling to minimize overhead
+ try:
+ return self._operations[task_id][agent_phase]
+ except KeyError:
+ return None
def _remove_operations(self, task_id: str) -> None:
if task_id in self._operations: