[Python-Dev] Twisted Isn't Specific (was Re: Trial balloon: microthreads library in stdlib)
Greg Ewing
greg.ewing at canterbury.ac.nz
Thu Feb 15 06:25:35 CET 2007
Thomas Wouters wrote:
> *I* don't like the idea of something in the Python installation
> deciding which reactor to use.
I wouldn't mind if some way were provided of changing
the reactor if you want. I'd just like to see a long
term goal of making it unnecessary as far as possible.
> In any case, your idea requires a lot of changes in external, non-Python
> code -- PyGTK simply exposes the GTK mainloop, which couldn't care less
> about Python's idea of a perfect event reactor model.
On unix at least, I don't think it should be necessary
to change gtk, only pygtk. If it can find out the file
descriptor of the connection to the X server, it can
plug that into the reactor, and then call
gtk_main_iteration_do() whenever something comes in
on it.
A similar strategy ought to work for any X11-based
toolkit that exposes a function to perform one
iteration of its main loop.
Mileage on other platforms may vary.
> The PerfectReactor can be added later, all current reactors
> aliased to it, and no one would have to change a single line
> of code.
Sure.
The other side to all this is the client side, i.e. the
code that installs event callbacks. At the moment there's
no clear direction to take, so everyone makes their own
choice -- some use asyncore, some use Twisted, some use
the gtk event loop, some roll their own, etc.
If it were made known that asyncore or some other thing
in the stdlib was intended to become the standard, then
it would give people some guidance as to how to write
future event-driven code.
--
Greg
More information about the Python-Dev
mailing list