There is a library that uses blocking requests
in its core and I would like to rewrite it into asynchronous version, so could you please advise what would be the best/easiest strategy to do so.
The whole library, after several nested functions, calls one function:
def _send_http_request(self, url, payload, method='post', **kwargs):
# type: (Text, Optional[Text], Text, dict) -> Response
response = request(method=method, url=url, data=payload, **kwargs)
return response
Just putting async
in front of it wont work since it is deeply nested in blocking functions. And rewriting everything would be a way too much hassle.
I had a look into aiohttp
, trio
, asks
and kinda got lost, which one is better. I know about celery
or dask
, but I need async.