pandas-datareader
pandas-datareader copied to clipboard
asyncio support for http requests.
While most of pandas is CPU bound, so would make sense running in a dedicated process. This particular module is very IO heavy.
I would like to make use of some of these methods in a Sanic web app, however the following code would stall the web server for all requests:
import pandas_datareader as pdr
@app.route('yahoo/aapl')
async def aapl():
return process_response(pdr.get_data_yahoo('AAPL')) # blocks, and stalls all other requests!
however with this code, I can wait for the yahoo API call while all my other web server requests are processed:
from pandas_datareader import aio as pdr
@app.route('yahoo/aapl')
async def aapl():
return process_response(await pdr.get_data_yahoo('AAPL')) # suspends coroutine, other coroutines can process other requests.
Description, reason for adding?
@bashtage done
Does this impose minimum Python version? In particular, does it work for 2.7?
There's trollius for legacy pythons, but yes it would. I envisaged this as a shared sans-io core with asyncio and synchronous apis made available separately
@graingert with pdr moving to Python3 only, would you offer a prototype PR for this?
@graingert I'm running into a situation where this would be very useful. Do you know if this was ever implemented, here or elsewhere?