1
# -*- test-case-name: twisted.test.test_stdio.StandardInputOutputTestCase.test_lastWriteReceived -*-
2
# Copyright (c) 2007 Twisted Matrix Laboratories.
3
# See LICENSE for details.
6
Main program for the child process run by
7
L{twisted.test.test_stdio.StandardInputOutputTestCase.test_lastWriteReceived}
8
to test that L{os.write} can be reliably used after
9
L{twisted.internet.stdio.StandardIO} has finished.
14
from twisted.internet.protocol import Protocol
15
from twisted.internet.stdio import StandardIO
16
from twisted.python.reflect import namedAny
19
class LastWriteChild(Protocol):
20
def __init__(self, reactor, magicString):
21
self.reactor = reactor
22
self.magicString = magicString
25
def connectionMade(self):
26
self.transport.write(self.magicString)
27
self.transport.loseConnection()
30
def connectionLost(self, reason):
35
def main(reactor, magicString):
36
p = LastWriteChild(reactor, magicString)
42
if __name__ == '__main__':
43
namedAny(sys.argv[1]).install()
44
from twisted.internet import reactor
45
main(reactor, sys.argv[2])