shazamio / ShazamIO

🎵 Is a free asynchronous library from reverse engineered Shazam API written in Python 3.8+ with asyncio and aiohttp.
MIT License
490 stars 69 forks source link

Cache aiohttp.ClientSession #83

Open averyanalex opened 8 months ago

averyanalex commented 8 months ago

From aiohttp docs:

The session contains a cookie storage and connection pool, thus cookies and connections are shared between HTTP requests sent by the same session.

Thus, using the same ClientSession can speed up execution of multiple requests in a row.

averyanalex commented 8 months ago

This also fixed OSError: [WinError 121] The semaphore timeout period has expired error in my program that sends 100 requests at the same time.

dotX12 commented 7 months ago

@averyanalex, hi! Oh, this is a serious update that will entail a major change in the code for users. I'll think about how this can be done better...

averyanalex commented 7 months ago

@averyanalex, hi! Oh, this is a serious update that will entail a major change in the code for users. I'll think about how this can be done better...

My friend told me that .stop() is not the best way. It maybe can be done more correctly with context manager. Sorry for my english.