Skip to content

Commit

Permalink
remove async in for loop
Browse files Browse the repository at this point in the history
  • Loading branch information
adrn committed Nov 1, 2024
1 parent 34a8f0b commit 78bb72d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
12 changes: 3 additions & 9 deletions astropylibrarian/algolia/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,12 @@ async def __aexit__(
await self.algolia_client.close()
self._logger.debug("Finished closing algolia client")

async def browse_objects(
self, browse_params: BrowseParamsObject
) -> BrowseResponse:
async def browse_objects(self, browse_params: BrowseParamsObject) -> BrowseResponse:
return await self.algolia_client.browse_objects(
index_name=self.name, aggregator=None, browse_params=browse_params
)

async def save_objects(
self, objects: list[dict[str, Any]]
) -> list[BatchResponse]:
async def save_objects(self, objects: list[dict[str, Any]]) -> list[BatchResponse]:
return await self.algolia_client.save_objects(self.name, objects)

async def delete_objects(self, objectids: list[str]) -> list[BatchResponse]:
Expand Down Expand Up @@ -148,9 +144,7 @@ async def browse_objects(
for _ in range(5):
yield {}

async def delete_objects(
self, objectids: list[str]
) -> list[DeletedAtResponse]:
async def delete_objects(self, objectids: list[str]) -> list[DeletedAtResponse]:
return [DeletedAtResponse(task_id=0, deleted_at="") for _ in objectids]


Expand Down
2 changes: 1 addition & 1 deletion astropylibrarian/workflows/expirerecords.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async def expire_old_records(
attributes_to_highlight=[],
)
old_object_ids: List[str] = []
async for r in algolia_index.browse_objects(obj):
for r in algolia_index.browse_objects(obj):
# Double check that we're deleting the right things.
if r["root_url"] != root_url:
logger.warning("root_url does not match: %s", r["baseUrl"])
Expand Down

0 comments on commit 78bb72d

Please sign in to comment.