[Python-ideas] The async API of the future
Amaury Forgeot d'Arc
amauryfa at gmail.com
Wed Jan 16 19:15:05 CET 2013
2013/1/16 Paul Moore <p.f.moore at gmail.com>
> On 3 November 2012 21:20, Richard Oudkerk <shibturn at gmail.com> wrote:
> > The IOCP proactor does not support ssl (or ipv6) so main.py does not
> succeed
> > in downloading from xkcd.com using ssl. Using the other proactors it
> works
> > correctly.
> >
> > The basic interface for the proactor looks like
> >
> > class Proactor:
> > def recv(self, sock, n): ...
> > def send(self, sock, buf): ...
> > def connect(self, sock, address): ...
> > def accept(self, sock): ...
> >
> > def poll(self, timeout=None): ...
> > def pollable(self): ...
>
> I've just been looking at this, and from what I can see, am I right in
> thinking that the IOCP support is *only* for sockets? (I'm not very
> familiar with socket programming, so I had a bit of difficulty
> following the code). In particular, it can't be used to register
> non-socket file objects? From my understanding of the IOCP
> documentation on MSDN, this is fundamental - IOCP can only be used on
> HANDLE objects that have been opened with the FILE_FLAG_OVERLAPPED
> flag, which is not used by "normal" Python IO objects like file
> handles and pipes, so it will never be possible to poll these objects
> using IOCP.
>
It works for disk files as well, but you indeed have to pass
FILE_FLAG_OVERLAPPED when opening the file.
This is similar to sockets: s.setblocking(False) is required for
asynchronous writes to work.
--
Amaury Forgeot d'Arc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130116/6403bb9b/attachment.html>
More information about the Python-ideas
mailing list