[Twisted-Python] FW: reject all open connections
exarkun at divmod.com
Thu Jun 26 17:18:42 EDT 2008
On Thu, 26 Jun 2008 23:08:00 +0200, Irae Hueck Costa <iraehc at hotmail.com> wrote:
>i just want to clean my reactor - all readers and writer should looseConnection()
>but how can i do this? reactor.removeAll() dont do it.
>the best solutions i found was a horrible workaround:
>a thread is tarted, which constantly calls ``[conn.loseConnection() for conn in reactor.removeAll()]``
>is there a better solution?
This is an unusual thing to want to do. Any code that does it risks
stomping on other code it doesn't know about. If you have a factory
serving connections on a particular port, you might want to have that
factory keep track of all clients which are connected to it, then it
can iterate over those clients and disconnect them.
If you use removeAll(), then you'll probably end of breaking some
reactor internals (like threading support and maybe other stuff).
However, if that's your goal, then the list comprehension you
pasted is more or less correct.
More information about the Twisted-Python