Skip to content

Commit 2f96929

Browse files
authored
Improve USE WORKSPACE reliability (#104)
* Increase USE WORKSPACE timeout * Do not raise exception on timeout
1 parent f0648d6 commit 2f96929

File tree

2 files changed

+32
-27
lines changed

2 files changed

+32
-27
lines changed

singlestoredb/fusion/handlers/workspace.py

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -107,32 +107,37 @@ def run(self, params: Dict[str, Any]) -> Optional[FusionSQLResult]:
107107

108108
workspace_id = workspace.id
109109

110-
# Set workspace and database
111-
if params.get('with_database'):
112-
if params.get('in_group'):
113-
# Use 3-element tuple: (workspace_group_id, workspace_name_or_id,
114-
# database)
115-
portal.connection = ( # type: ignore[assignment]
116-
workspace_group.id,
117-
workspace_name or workspace_id,
118-
params['with_database'],
119-
)
120-
else:
121-
# Use 2-element tuple: (workspace_name_or_id, database)
122-
portal.connection = (
123-
workspace_name or workspace_id,
124-
params['with_database'],
125-
)
126-
else:
127-
if params.get('in_group'):
128-
# Use 2-element tuple: (workspace_group_id, workspace_name_or_id)
129-
portal.workspace = ( # type: ignore[assignment]
130-
workspace_group.id,
131-
workspace_name or workspace_id,
132-
)
110+
try:
111+
# Set workspace and database
112+
if params.get('with_database'):
113+
if params.get('in_group'):
114+
# Use 3-element tuple: (workspace_group_id, workspace_name_or_id,
115+
# database)
116+
portal.connection = ( # type: ignore[assignment]
117+
workspace_group.id,
118+
workspace_name or workspace_id,
119+
params['with_database'],
120+
)
121+
else:
122+
# Use 2-element tuple: (workspace_name_or_id, database)
123+
portal.connection = (
124+
workspace_name or workspace_id,
125+
params['with_database'],
126+
)
133127
else:
134-
# Use string: workspace_name_or_id
135-
portal.workspace = workspace_name or workspace_id
128+
if params.get('in_group'):
129+
# Use 2-element tuple: (workspace_group_id, workspace_name_or_id)
130+
portal.workspace = ( # type: ignore[assignment]
131+
workspace_group.id,
132+
workspace_name or workspace_id,
133+
)
134+
else:
135+
# Use string: workspace_name_or_id
136+
portal.workspace = workspace_name or workspace_id
137+
138+
except RuntimeError as exc:
139+
if 'timeout' not in str(exc):
140+
raise
136141

137142
return None
138143

singlestoredb/notebook/_portal.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ def _call_javascript(
5656
args: Optional[List[Any]] = None,
5757
wait_on_condition: Optional[Callable[[], bool]] = None,
5858
timeout_message: str = 'timed out waiting on condition',
59-
wait_interval: float = 0.2,
60-
timeout: float = 5.0,
59+
wait_interval: float = 2.0,
60+
timeout: float = 60.0,
6161
) -> None:
6262
if not has_ipython or not func:
6363
return

0 commit comments

Comments
 (0)