[Twisted-Python] client API issue for Application
I've been talking with nobomb on #twisted about his IRC bot, which he wants to be able to connect to a list of servers for fail-over (i.e., when one server connection fails, try to connect to the nest). We worked it out so that he'd call app.connectTCP again in his clientConnectionFailed method of his ClientFactory, but I realized that the tcpConnectors list in Application *never* gets cleaned out. Should we have an explicit method to do this, or some kind of automatic cleaning, or something...? While browsing through the Application source, I see that the same is true for the listeners, except for TCP (there's an unlistenTCP, but no unlistenSSL, frex). There's *also* a dontListenTCP which just raises a not implemented error. *boggle* -- Chris Armstrong << radix@twistedmatrix.com >> http://twistedmatrix.com/users/radix.twistd/
Christopher Armstrong wrote:
I've been talking with nobomb on #twisted about his IRC bot, which he wants to be able to connect to a list of servers for fail-over (i.e., when one server connection fails, try to connect to the nest). We worked it out so that he'd call app.connectTCP again in his clientConnectionFailed method of his ClientFactory, but I realized that the tcpConnectors list in Application *never* gets cleaned out. Should we have an explicit method to do this, or some kind of automatic cleaning, or something...?
If you don't want a connection to persist, don't add it to Application. Since a connection to an IRC server shouldn't persist (you may be connecting to other servers), it should be added to reactor directly. Since you apparently want *something* to persist, you probably want to add a twisted.internet.app.ApplicationService that will manage the connections. -- Itamar Shtull-Trauring http://itamarst.org/ Available for Python, Twisted, Zope and Java consulting
participants (2)
-
Christopher Armstrong
-
Itamar Shtull-Trauring