4 ms·
>I did this for two reasons, the first being that I cannot, for the life of me, figure out how to use asyncio to do local file IO and not a network request, but
by btreecat 11y ago
>I did this for two reasons, the first being that I cannot, for the life of me, figure out how to use asyncio to do local file IO and not a network request, but maybe I'm just an idiot.
I don't think you are an idiot I just think you didn't search well enough. There is a reason there is no local file IO with asyncio.
Check these links for more info:
* https://stackoverflow.com/questions/87892/what-is-the-status-of-posix-asynchronous-i-o-aio https://stackoverflow.com/questions/87892/what-is-the-status...
* http://blog.libtorrent.org/2012/10/asynchronous-disk-io/ http://blog.libtorrent.org/2012/10/asynchronous-disk-io/
From what I understand the way libuv (what node.js uses) gets around OS limits is with a thread pool.
Also, this documentation might be helpful:
* https://docs.python.org/3.5/library/asyncio-dev.html#handle-blocking-functions-correctly https://docs.python.org/3.5/library/asyncio-dev.html#handle-...
My experiences don't seem to mirror your frustration. I found asyncio quite useful for tinkering with a simple web scraper that hit multiple sites at once (each with a different response time) and munged all the data together into one data set.
Thanks for the write-up!
- sonicrocketman 11y agoThanks for the suggestions!
- sandGorgon 11y agohave you used a database in a non-blocking way with asyncio ? I'm thinking of the way Psycogreen works or node-postgres works.
- ikken 11y agoPlease check aiopg [1]. There's also an interesting list of packages for asyncio [2]. [1] https://aiopg.readthedocs.org/en/stable/ https://aiopg.readthedocs.org/en/stable/ [2] http://asyncio.org/ http://asyncio.org/