Reviving the thread... if I understand correctly, there is no portable way 
to do disk I/O asynchronously (and the gist [1] provided by the OP is 
bogus: the read_data function will block the event loop). Is my 
understanding correct?

[1] https://gist.github.com/kunev/f83146d407c81a2d64a6 
<https://www.google.com/url?q=https%3A%2F%2Fgist.github.com%2Fkunev%2Ff83146d407c81a2d64a6&sa=D&sntz=1&usg=AFQjCNG-U5Mxoo48n49VafkFEr4TnQVm8g>

Second question: Node.js does have a complete async API for doing filesysem 
I/O, even an async stat function! But after reading Glyph's Q&A on 
Stackoverflow I conclude those filesystem I/O functions in Node must rely 
on threads underneath, since we can't rely on OS APIs for async filesystem 
I/O. Is that it?

Thanks!

Best,

Luciano


On Tuesday, August 26, 2014 at 11:11:51 PM UTC-3, Glyph Lefkowitz wrote:
>
> If anyone is curious about the abysmal state of asynchronous file I/O in 
> popular operating systems, this question I asked on Stack Overflow a while 
> back has got some really excellent answers on it: <
> https://stackoverflow.com/questions/87892/what-is-the-status-of-posix-asynchronous-i-o-aio
> >.
>
> -glyph
>
> On Aug 25, 2014, at 6:55 PM, Guido van Rossum <[email protected] 
> <javascript:>> wrote:
>
> On most OSes, select() and other polling APIs always report disk files to 
> be "ready", so you basically can't use asyncio with them. On Windows it 
> will fail; on *n*x it will appear to work but actually you are doing the 
> whole thing synchronously. The only way to overlap disk I/O with asyncio 
> events would be to do the disk I/O on a separate thread.
>
> Someone is working on sendfile support (
> https://code.google.com/p/tulip/issues/detail?id=144, 
> http://bugs.python.org/issue17552) which would help overlap disk I/O and 
> socket I/O for the specific case of serving a file from disk directly to a 
> socket, but even that would be pretty limited.
>
>
> On Mon, Aug 25, 2014 at 3:06 PM, Ludovic Gasc <[email protected] 
> <javascript:>> wrote:
>
>> Hi,
>>
>> I'm looking for the best way to read/write files with AsyncIO.
>> Ideally, I want to r/w asynchronously, like with network.
>>
>> I've found this: https://gist.github.com/kunev/f83146d407c81a2d64a6
>>
>> Is it ok, or do you have a better suggestion ?
>>
>> Regards.
>>
>
>
>
> -- 
> --Guido van Rossum (python.org/~guido) 
>
>
>

Reply via email to