raise occupied exception before creating workflow (#4126)
This commit is contained in:
@@ -777,8 +777,8 @@ class LLMCallerNotFoundError(SkyvernException):
|
|||||||
|
|
||||||
|
|
||||||
class BrowserSessionAlreadyOccupiedError(SkyvernHTTPException):
|
class BrowserSessionAlreadyOccupiedError(SkyvernHTTPException):
|
||||||
def __init__(self, browser_session_id: str) -> None:
|
def __init__(self, browser_session_id: str, runnable_id: str) -> None:
|
||||||
super().__init__(f"Browser session {browser_session_id} is already occupied")
|
super().__init__(f"Browser session {browser_session_id} is already occupied by {runnable_id}")
|
||||||
|
|
||||||
|
|
||||||
class BrowserSessionNotRenewable(SkyvernException):
|
class BrowserSessionNotRenewable(SkyvernException):
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ from skyvern.constants import GET_DOWNLOADED_FILES_TIMEOUT, SAVE_DOWNLOADED_FILE
|
|||||||
from skyvern.exceptions import (
|
from skyvern.exceptions import (
|
||||||
BlockNotFound,
|
BlockNotFound,
|
||||||
BrowserProfileNotFound,
|
BrowserProfileNotFound,
|
||||||
|
BrowserSessionAlreadyOccupiedError,
|
||||||
BrowserSessionNotFound,
|
BrowserSessionNotFound,
|
||||||
CannotUpdateWorkflowDueToCodeCache,
|
CannotUpdateWorkflowDueToCodeCache,
|
||||||
FailedToSendWebhook,
|
FailedToSendWebhook,
|
||||||
@@ -404,6 +405,27 @@ class WorkflowService:
|
|||||||
workflow_request.proxy_location = workflow.proxy_location
|
workflow_request.proxy_location = workflow.proxy_location
|
||||||
if workflow_request.webhook_callback_url is None and workflow.webhook_callback_url is not None:
|
if workflow_request.webhook_callback_url is None and workflow.webhook_callback_url is not None:
|
||||||
workflow_request.webhook_callback_url = workflow.webhook_callback_url
|
workflow_request.webhook_callback_url = workflow.webhook_callback_url
|
||||||
|
|
||||||
|
if workflow_request.browser_session_id:
|
||||||
|
persistent_browser_session = await app.DATABASE.get_persistent_browser_session(
|
||||||
|
workflow_request.browser_session_id, organization.organization_id
|
||||||
|
)
|
||||||
|
if persistent_browser_session is None:
|
||||||
|
LOG.warning(
|
||||||
|
"Failed to create workflow run, browser sesssion not found",
|
||||||
|
browser_session_id=workflow_request.browser_session_id,
|
||||||
|
)
|
||||||
|
raise BrowserSessionNotFound(workflow_request.browser_session_id)
|
||||||
|
|
||||||
|
if persistent_browser_session.runnable_id:
|
||||||
|
LOG.warning(
|
||||||
|
"Failed to create workflow run, browser session is already occupied",
|
||||||
|
browser_session_id=workflow_request.browser_session_id,
|
||||||
|
)
|
||||||
|
raise BrowserSessionAlreadyOccupiedError(
|
||||||
|
workflow_request.browser_session_id, persistent_browser_session.runnable_id
|
||||||
|
)
|
||||||
|
|
||||||
# Create the workflow run and set skyvern context
|
# Create the workflow run and set skyvern context
|
||||||
workflow_run = await self.create_workflow_run(
|
workflow_run = await self.create_workflow_run(
|
||||||
workflow_request=workflow_request,
|
workflow_request=workflow_request,
|
||||||
|
|||||||
Reference in New Issue
Block a user