@@ -1152,27 +1152,34 @@ async def destroy(request: web.Request, params: Any) -> web.Response:
1152
1152
if params ["recursive" ]:
1153
1153
async with root_ctx .db .begin_readonly_session () as db_sess :
1154
1154
dependent_session_ids = await find_dependent_sessions (
1155
- session_name , db_sess , owner_access_key
1155
+ session_name ,
1156
+ db_sess ,
1157
+ owner_access_key ,
1158
+ allow_stale = True ,
1156
1159
)
1157
1160
1158
1161
target_session_references : List [str | uuid .UUID ] = [
1159
1162
* dependent_session_ids ,
1160
1163
session_name ,
1161
1164
]
1162
- sessions = [
1163
- await SessionRow .get_session (
1164
- db_sess ,
1165
- name_or_id ,
1166
- owner_access_key ,
1167
- kernel_loading_strategy = KernelLoadingStrategy .ALL_KERNELS ,
1168
- )
1169
- for name_or_id in target_session_references
1170
- ]
1165
+ sessions : Iterable [SessionRow | Exception ] = await asyncio .gather (
1166
+ * [
1167
+ SessionRow .get_session (
1168
+ db_sess ,
1169
+ name_or_id ,
1170
+ owner_access_key ,
1171
+ kernel_loading_strategy = KernelLoadingStrategy .ALL_KERNELS ,
1172
+ )
1173
+ for name_or_id in target_session_references
1174
+ ],
1175
+ return_exceptions = True ,
1176
+ )
1171
1177
1172
1178
last_stats = await asyncio .gather (
1173
1179
* [
1174
1180
root_ctx .registry .destroy_session (sess , forced = params ["forced" ])
1175
1181
for sess in sessions
1182
+ if isinstance (sess , SessionRow )
1176
1183
],
1177
1184
return_exceptions = True ,
1178
1185
)
@@ -1570,6 +1577,8 @@ async def find_dependent_sessions(
1570
1577
root_session_name_or_id : str | uuid .UUID ,
1571
1578
db_session : SASession ,
1572
1579
access_key : AccessKey ,
1580
+ * ,
1581
+ allow_stale : bool = False ,
1573
1582
) -> Set [uuid .UUID ]:
1574
1583
async def _find_dependent_sessions (session_id : uuid .UUID ) -> Set [uuid .UUID ]:
1575
1584
result = await db_session .execute (
@@ -1588,7 +1597,10 @@ async def _find_dependent_sessions(session_id: uuid.UUID) -> Set[uuid.UUID]:
1588
1597
return dependent_sessions
1589
1598
1590
1599
root_session = await SessionRow .get_session (
1591
- db_session , root_session_name_or_id , access_key = access_key
1600
+ db_session ,
1601
+ root_session_name_or_id ,
1602
+ access_key = access_key ,
1603
+ allow_stale = allow_stale ,
1592
1604
)
1593
1605
return await _find_dependent_sessions (cast (uuid .UUID , root_session .id ))
1594
1606
0 commit comments