Skip to content

Commit

Permalink
Fix house keeping
Browse files Browse the repository at this point in the history
  • Loading branch information
oeway committed Dec 18, 2024
1 parent b25492d commit 039059c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion hypha/VERSION
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "0.20.44.post3"
"version": "0.20.44.post4"
}
21 changes: 11 additions & 10 deletions hypha/core/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,21 +308,22 @@ async def housekeeping(self):
logger.info("Skipping housekeeping on first run")
self._first_run = False
return
try:
logger.info(f"Running housekeeping task at {datetime.datetime.now()}")
async with self.get_workspace_interface(
self._root_user, "ws-user-root", client_id="housekeeping"
) as api:
# admin = await api.get_service("admin-utils")
workspaces = await api.list_workspaces()
for workspace in workspaces:

logger.info(f"Running housekeeping task at {datetime.datetime.now()}")
async with self.get_workspace_interface(
self._root_user, "ws-user-root", client_id="housekeeping"
) as api:
# admin = await api.get_service("admin-utils")
workspaces = await api.list_workspaces()
for workspace in workspaces:
try:
summary = await api.cleanup(workspace.id)
if "removed_clients" in summary:
logger.info(
f"Removed {len(summary['removed_clients'])} clients from workspace {workspace.id}"
)
except Exception as e:
logger.exception(f"Error in housekeeping: {e}")
except Exception as e:
logger.exception(f"Error in housekeeping {workspace}: {e}")

async def upgrade(self):
"""Upgrade the store."""
Expand Down
2 changes: 1 addition & 1 deletion hypha/core/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -1892,7 +1892,7 @@ async def cleanup(
client_keys = await self._list_client_keys(workspace)
if len(client_keys) <= 0:
await self.delete_workspace(workspace_info.id, context=context)
return {"removed_workspace": 1, "removed_clients": 0}
return {"removed_workspace": workspace_info.id, "removed_clients": []}
removed = []
summary = {}
if not workspace_info.persistent:
Expand Down

0 comments on commit 039059c

Please sign in to comment.