Opened 9 years ago

Last modified 9 years ago

#6344 enhancement reopened

Export function to create preferred reactor from twisted.internet.default without installing it

Reported by: mbeyer Owned by:
Priority: low Milestone:
Component: core Keywords:
Cc: Branch:
Author:

Description

I find it occasionally useful to wrap the platform specific reactor to extend it with some additional functionality and then install it manually using t.a.r.installReactor. Since twisted.internet.default currently only exports the install function, I have to determine the preferred platform reactor by myself. It would be nice if twisted would export the preferred reactor class as well as the install function since it is basically determined by twisted.internet.default anyways.

Change History (3)

comment:1 Changed 9 years ago by Jean-Paul Calderone

Resolution: wontfix
Status: newclosed

I don't think we want to encourage people to subclass reactors. We also don't want to encourage people to continue to rely on the global reactor, either.

I suggest you *wrap* the installed reactor and pass the wrapper around to all your code.

comment:2 in reply to:  1 Changed 9 years ago by Glyph

Resolution: wontfix
Status: closedreopened
Summary: Export reactor class from twisted.internet.defaultExport function to create preferred reactor from twisted.internet.default without installing it

Replying to exarkun:

I don't think we want to encourage people to subclass reactors. We also don't want to encourage people to continue to rely on the global reactor, either.

The reporter never said "subclass". They specifically said "wrap", as you suggest below - now, granted, they did say "extend", but I took that to mean, like, proxyForInterface. So you are responding to something they didn't actually say.

I suggest you *wrap* the installed reactor and pass the wrapper around to all your code.

But what if you want to wrap the reactor that all of Twisted itself is importing? The global reactor is a fact of life, and as much as we'd like to gently discourage it we have no other mechanism for accessing the currently active reactor on the stack, and we shouldn't pretend you don't need to change it sometimes.

What the reporter really seems to want here is a way to create the default reactor without installing it - a way to query Twisted's preferences without mutating global state. That seems like a reasonable proposition to me.

So I got rid of the word "class" from the summary.

comment:3 Changed 9 years ago by Glyph

Priority: normallow

On the other hand, probably not one of the most important features one could add. In the spirit of always having something better to suggest, how about making endpoints feature-complete by adding a service to connect clients as well as servers?

Note: See TracTickets for help on using tickets.