Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/fix-it' into fix-it
Browse files Browse the repository at this point in the history
  • Loading branch information
Konstantin committed Feb 5, 2025
2 parents 7245761 + 519d7e7 commit 1025287
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/edi_energy_scraper/scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ def __init__(
self._session = aiohttp.ClientSession(connector=self.tcp_connector)
self._timeout = ClientTimeout(total=30.0)

async def close(self) -> None:
"""Properly closes the aiohttp session."""
if self._session and not self._session.closed:
await self._session.close()
if not self.tcp_connector.closed:
await self.tcp_connector.close()

async def get_documents_overview(self) -> list[Document]:
"""
download meta information about all available documents
Expand Down Expand Up @@ -163,5 +170,10 @@ async def get_best_match(
downloaded_path.rename(path)
return path

def __del__(self) -> None:
"""Ensure cleanup when the instance is destroyed."""
if not self._session.closed:
asyncio.create_task(self.close())


__all__ = ["EdiEnergyScraper"]

0 comments on commit 1025287

Please sign in to comment.