File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,13 @@ def __init__(
4343 self ._session = aiohttp .ClientSession (connector = self .tcp_connector )
4444 self ._timeout = ClientTimeout (total = 30.0 )
4545
46+ async def close (self ) -> None :
47+ """Properly closes the aiohttp session."""
48+ if self ._session and not self ._session .closed :
49+ await self ._session .close ()
50+ if not self .tcp_connector .closed :
51+ await self .tcp_connector .close ()
52+
4653 async def get_documents_overview (self ) -> list [Document ]:
4754 """
4855 download meta information about all available documents
@@ -153,5 +160,10 @@ async def get_best_match(
153160 downloaded_path .rename (path )
154161 return path
155162
163+ def __del__ (self ) -> None :
164+ """Ensure cleanup when the instance is destroyed."""
165+ if not self ._session .closed :
166+ asyncio .create_task (self .close ())
167+
156168
157169__all__ = ["EdiEnergyScraper" ]
You can’t perform that action at this time.
0 commit comments