reactor/proactor

59 views
Skip to first unread message

Andrew McNabb

unread,
Apr 9, 2009, 8:05:20 PM4/9/09
to co...@googlegroups.com
I checked out a copy of the cogen tree with git-svn today, and I'm
familiarizing myself with the code. I hope you don't mind if I ask some
questions over the next few days.

1) I went to the examples directory and looked at the
helloword-wsgi-app.py. The first thing I noticed was how many times I
saw "proactor" (proactor_resolution, proactor_greedy,
proactor_multiplex_first). After looking at cogen/core/proactors/*.py,
it made me wonder whether "proactor" is actually a bit of a misnomer.
I'm not a huge design patterns guy, so I could be wrong, but the
following page seems to say that reactors are for select/poll sorts of
stuff, and proactors are for when the kernel itself does IO.

http://www.artima.com/articles/io_design_patterns2.html

From this description, it sounds like what Cogen does isn't exactly a
reactor or a proactor but a sort of hybrid. It's not a hugely important
issue, but I am curious if there's more to it.

2) I was a bit confused when I saw has_ctypes_iocp (in
proactors/__init__.py) because it returns CTYPES_IOCPProactor as long as
there's no ImportError. Within the context of __init__.py, it seemed
like it should always be possible to import ctypes and ctypes_iocp_impl
regardless of whether this implementation is available. When running it
by hand, though, I noticed that the actual ImportError raised is
"ImportError: cannot import name WINFUNCTYPE". It works, but it seemed
a little misleading.

3) It looks like there's a genuine bug on line 63 of
proactors/__init__.py in has_iocp. Shouldn't that be a return rather
than a pass?

Thanks.


--
Andrew McNabb
http://www.mcnabbs.org/andrew/
PGP Fingerprint: 8A17 B57C 6879 1863 DE55 8012 AB4D 6098 8826 6868

Ionel Maries Cristian

unread,
Apr 10, 2009, 3:06:08 AM4/10/09
to co...@googlegroups.com
1) The name "proactor" refers to the interface (or functionality) that the class offers. Only the windows IOCP ones rely on true proactor os api, the others (select, poll, epoll, kqueue) simulate a proactor over the reactor interfaces that the OS offers.

2) I want to enforce as less as possible. One should use the has_blabla() to check if a specific implementation is available. If you directly import the class you do it at your own peril.

Anyway - it seemed sensible to me to do it that way.

3) Yep, to my shame that's true. At some point I had a warning+return there and someone complained about the warnings. I think it's this way because i forgot to add that warning back after I changed the proactor priorities (ctypes_iocp before the pywin32 iocp).

-- ionel

Andrew McNabb

unread,
Apr 13, 2009, 1:51:09 PM4/13/09
to co...@googlegroups.com
On Fri, Apr 10, 2009 at 10:06:08AM +0300, Ionel Maries Cristian wrote:
> 1) The name "proactor" refers to the interface (or functionality) that the
> class offers. Only the windows IOCP ones rely on true proactor os api, the
> others (select, poll, epoll, kqueue) simulate a proactor over the reactor
> interfaces that the OS offers.

Fair enough. It still sets off my buzzword alarm but at least it makes
sense. :)


> 2) I want to enforce as less as possible. One should use the has_blabla()
> to check if a specific implementation is available. If you directly import
> the class you do it at your own peril.

Sorry, I should rephrase my comment.

It seems like it would be a little more consistent with the surrounding
code if it looked something like this:

import ctypes
from ctypes import WINFUNCTYPE
import ctypes_iocp_impl

I was confused when I read the original because it made it look like the
only condition needed was that ctypes could be successfully imported,
but it's actually importing WINFUNCTYPE that seems to make it fail on my
machine. It's not a big deal, I just thought I would mention it.

Reply all
Reply to author
Forward
0 new messages