Let's say I have the following program
import requests
async def foo():
res = await get_resource()
status_code = await make_request(res)
print(f"status code: {status_code}\n", res)
async def get_resource():
# ...
with open('file') as f:
return f.read()
async def make_request(data):
return requests.post('/create', data=data).status_code
This program gains nothing from being async
and can hamper the performance of other code on the event loop. Obviously, this is a simple example, but across multiple files and developers, it may not be so easy to spot.
It would be awesome if I could add something to my build pipeline that could detect this case. Is there any Python build tool that will indicate that this async code is requiesting synchronous I/O?