13
from twisted.internet.error import ConnectionDone
13
14
from twisted.internet import stdio, protocol
14
from twisted.python import reflect
15
from twisted.python import reflect, log
16
17
class LoseConnChild(protocol.Protocol):
17
20
def connectionMade(self):
18
21
self.transport.loseConnection()
21
24
def connectionLost(self, reason):
26
Check that C{reason} is a L{Failure} wrapping a L{ConnectionDone}
27
instance and stop the reactor. If C{reason} is wrong for some reason,
28
log something about that in C{self.errorLogFile} and make sure the
29
process exits with a non-zero status.
33
reason.trap(ConnectionDone)
35
log.err(None, "Problem with reason passed to connectionLost")
25
41
if __name__ == '__main__':
26
42
reflect.namedAny(sys.argv[1]).install()
43
log.startLogging(file(sys.argv[2], 'w'))
27
44
from twisted.internet import reactor
28
stdio.StandardIO(LoseConnChild())
45
protocol = LoseConnChild()
46
stdio.StandardIO(protocol)
48
sys.exit(protocol.exitCode)