Recently I have wanted to use Python async/await on local file IO, however I find it's impossible after reading following links:
Does asyncio supports asynchronous I/O for file operations?
Read file line by line with asyncio
The solution is the aiofiles modules, which is based on threads. But in Nodejs it's so perfect and easy to make file IO async just using fs modules which are based on standard POSIX functions. Why can't python do I/O async when nodejs can?
But Node.js async file I/O is also based on threads:
Note that all file system APIs except fs.FSWatcher() and those that are explicitly synchronous use libuv's threadpool, which can have surprising and negative performance implications for some applications, see the UV_THREADPOOL_SIZE documentation for more information.
– from https://nodejs.org/api/fs.html#fs_threadpool_usage
So Node.js fs API is doing the same thing as Python asyncio + aiofiles module.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With