Showing content from http://mail.python.org/pipermail/python-dev/attachments/20070215/d8aa6049/attachment.htm below:
<html><body><br />On 12:31 am, greg.ewing@canterbury.ac.nz wrote:<br />>glyph@divmod.com wrote:<br />>> On 08:52 pm, theller@ctypes.org wrote:<br />>><br />>>  >When I last looked at twisted (that is several years ago), there were<br />>>  >several reactors - win32reactor, wxreactor, maybe even more.<br />>><br />>> Only the very top-most level decides which reactor the application will use.<br />><br />>This is a worry, because it implies that there has to<br />>*be* a top level that knows what kind of reactor the<br />>whole application will use, and all parts of the<br />>application need to know that they will be getting<br />>their reactor from that top level.<br /><br />The default reactor is the most portable one, 'select', and if no other reactor  is installed, that's the one that will be used.<br /><br />>That may not be the case. For example, you want to<br />>incorporate some piece of event-driven code written<br />>by someone else into your gtk application. But it<br />>wasn't written with gtk in mind, so it doesn't know<br />>to use a gtkreactor, or how to get a reactor that it<br />>can use from your application.<br /><br />"from twisted.internet import reactor" is the way you get at the reactor, regardless of which one is currently installed.<br /><br />There can only be one reactor active at any given time, because at the very bottom of the event-handling machinery _some_ platform multiplexing API must be called, and that is mostly what the reactor represents.<br /><br />The GTK reactor does not have its own API.  It simply allows you to use GTK APIs as well, by back-ending to the glib mainloop.  That is, in fact, the whole point of having a "reactor" API in the first place.<br /><br />>This is not my idea of what another poster called a<br />>"one-stop shop" -- a common API that different pieces<br />>of code can call independently without having to know<br />>about each other.<br /><br />>To my mind, there shouldn't be a "reactor" object<br />>exposed to the application at all. There should just<br />>be functions for setting up callbacks.<br /><br />That's what the Twisted "reactor" object *is*, exactly.  Functions (well, methods) for setting up callbacks.<br /><br />>The choice of<br />>implementation should be made somewhere deep inside<br />>the library, based on what platform is being used.<br /><br />The "deep inside the library" decision is actually a policy decision made by a server's administrator, or dependent upon the GUI library being used if you need to interact with a GUI event loop.  Perhaps the default selection could be better, but installing a reactor is literally one line of code, or a single command-line option to the "twistd" daemon.  See:<br /><br />http://twistedmatrix.com/projects/core/documentation/howto/choosing-reactor.html<br /><br />It is completely transparent to the application, _unless_ the application wants to make use of platform-specific features.<br /><br />See the following for more information:<br /><br />http://www.cs.wustl.edu/~schmidt/PDF/reactor-siemens.pdf<br /><br />although technically Twisted's "reactor" is more like the slightly higher level POSA "proactor" pattern; asyncore is more like a true "reactor" in the sense discussed in that paper.<br /><br />Twisted exposes various APIs for "setting up callbacks" exactly as you describe:<br /><br />http://twistedmatrix.com/documents/current/api/twisted.internet.interfaces.IReactorTCP.html<br />http://twistedmatrix.com/documents/current/api/twisted.internet.interfaces.IReactorTime.html<br /><br />>So at this point I'm skeptical that the Twisted<br />>API for these things should be adopted as-is<br /><br />Given that your supporting arguments were almost exactly the opposite of the truth in every case, I think this conclusion should be re-examined :).  If you're interested in how a normal Twisted application looks, see this tutorial:<br /><br />http://twistedmatrix.com/projects/core/documentation/howto/servers.html<br /></body></html>
RetroSearch is an open source project built by @garambo
| Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4