[Twisted-Python] how to drop connection
Andrew Bennetts
andrew-twisted at puzzling.org
Wed Jul 30 00:41:00 MDT 2003
On Tue, Jul 29, 2003 at 11:33:37PM -0700, Brian Warner wrote:
> "Michael Porter" <mporter at despammed.com> writes:
> >
> > I'm trying to close down a web server (wihout closing the application) but
> > am having problems closing already established connections.
>
> Maybe something like this? (note: completely untested):
This technique looks feasible to me, except:
> class DroppingHTTPFactory(http.HTTPFactory):
>
> currentConnections = []
> protocol = DroppingHTTPChannel
>
> def stopFactory(self):
> http.HTTPFactory.stopFactory(self)
> for p in self.currentConnections:
> p.transport.loseConnection()
This really should be (also untested):
class DroppingHTTPFactory(http.HTTPFactory):
protocol = DroppingHTTPChannel
def startFactory(self):
http.HTTPFactory.startFactory(self)
self.currentConnections = []
def stopFactory(self):
http.HTTPFactory.stopFactory(self)
for p in self.currentConnections:
p.transport.loseConnection()
So that you can have multiple DroppingHTTPFactories without them interfering
with each other.
-Andrew.
More information about the Twisted-Python
mailing list