You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ludovic Gasc, python-tulip
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.
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to python...@googlegroups.com, gu...@python.org, gml...@gmail.com
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?
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
Andrew Svetlov
unread,
Jan 13, 2015, 10:29:26 AM1/13/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Luciano Ramalho, python...@googlegroups.com, Guido van Rossum, Ludovic Gasc
1. Yes, file functions from your gist do block event loop.
2. Yes, portable nonblocking file API should be built on threads. Or,
as an option, you can make *actually blocking* code with *nonblocking
interface* if you like coroutines so much.
--
Thanks,
Andrew Svetlov
Saúl Ibarra Corretgé
unread,
Jan 13, 2015, 10:32:04 AM1/13/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to python...@googlegroups.com
On 01/13/2015 03:54 PM, Luciano Ramalho wrote:
> 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
> 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?
>
libuv (Node's platform layer) core dev here. That's right all filesystem
operations are run in a threadpool, much like asyncio runs getaddrinfo
in a ThreadPoolExecutor.
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Saúl Ibarra Corretgé, python-tulip
2015-01-13 16:24 GMT+01:00 Saúl Ibarra Corretgé <sag...@gmail.com>:
> libuv (Node's platform layer) core dev here. That's right all filesystem
> operations are run in a threadpool, much like asyncio runs getaddrinfo
> in a ThreadPoolExecutor.
>
> Here is an interesting read:
> http://blog.libtorrent.org/2012/10/asynchronous-disk-io/
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Victor Stinner, Saúl Ibarra Corretgé, python-tulip
Interesting blog. The gist seems to be to use a thread pool for disk operations instead of AOI. This translates fairly directly to Tulip/Trollius, using the run_in_executor() operation. It's pretty clear to me that Windows IOCP does support async operations on disk files, so it would behoove us to design a standard API for async disk operations that can be implemented either using IOCP or using a thread pool.
Saúl Ibarra Corretgé
unread,
Jan 13, 2015, 11:40:08 AM1/13/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to gu...@python.org, Victor Stinner, python-tulip
On 01/13/2015 05:34 PM, Guido van Rossum wrote:
> Interesting blog. The gist seems to be to use a thread pool for disk
> operations instead of AOI. This translates fairly directly to
> Tulip/Trollius, using the run_in_executor() operation. It's pretty clear
> to me that Windows IOCP does support async operations on disk files, so
> it would behoove us to design a standard API for async disk operations
> that can be implemented either using IOCP or using a thread pool.
>
I can ask our resident Windows expert, but IIRC there was some problem
on Windows too. Something along the lines of async operations falling
back to being sync in certain conditions...