[Twisted-Python] Reactors and New Asynchronous APIs
Patrick Mézard
pmezard at gmail.com
Thu May 5 05:52:18 EDT 2005
Hello,
I have several questions about twisted reactors and extending the twisted
framework with new asynchronous APIs.
1- What is the status of the IOCP reactor? Is it stable? If it is, is there any
reason for not selecting it as the default reactor for win32 NT platforms?
2- I am considering the integration of a custom database API (like Berkeley DB)
in a twisted application. I could easily wrap the API in a C++ python module and
access it synchronously from twisted, at least in a prototyping phase.
Obviously, if the blocking calls are too long it would make the whole framework
completely useless. Then, the calls could be made from twisted managed threads.
Assuming the module code was written to minimize GIL contention it would
probably greatly improve the situation. The most efficient solution would be
to plug the asynchronous API directly into the reactor:
Is it possible to extend reactors with new asynchronous API implemented in
separate client modules?
With my little knowledge of the twisted framework and quick glances at the
selectreactor and iocpreactor implementation, I think the answer is no.
The practical solution would be to duplicate the reactor code and extend it
with the new API calls.
I do not know if it would be easy or not to provide a pluggable asynchronous
framework *at C module level*. Basically, the reactor is nothing else than a
thread-safe event queue with a (post/get)-event API. If this abstraction can be
implemented at C level, then plugging new asynchronous handlers would be clearly
doable, _iocp.c is a good example for that. Now, I am not really knowledgeable
(yet) about python C module coding, and I guess it is not exactly easy to bind
C callbacks from one python C module into another using normal python code as
glue. In the end, this is just another plugin/component system like COM to
write so...
Any thoughts?
Patrick Mézard
More information about the Twisted-Python
mailing list