tinify / tinify-python

Python client for the Tinify API.
https://tinypng.com/developers
MIT License
131 stars 21 forks source link

Optionally use aiohttp instead of requests if desired. #7

Closed AraHaan closed 7 years ago

AraHaan commented 7 years ago

Currently requests uses thread.sleep or w/e that can deadlock code that uses asyncio in python 3. Because of this aiohttp was created for use with async code that uses asyncio. As such it would be nice to support aiohttp first if they have aiohttp installed. Or provide an special class or something that us asyncio users can call with our async code to make the requests to this API. This is so our async code does not deadlock. If a class is made for this you guys can make it so that it is only shown when aiohttp is installed without explicitly requireing it to be installed.

Why aiohttp over requests?

Well aiohttp supports everything that requests does, but also for async code only. It is perfect for just about all sorts of web based requests in async code. For an example project that uses aiohttp and asyncio you can pip install discord.py or view it on github under Rapptz/discord.py.

simonwahlstrom commented 7 years ago

Hello AraHaan,

Thank you for bringing this to our attention. It does indeed sound like a nice suggestion and I will add it to our improvements list. Although I can't promise right now when or if it will be implemented.

If you want you are very welcome to make a pull request. That would probably speedup the process quite a lot.