Ticket #837: openSocketSpawner.py

File openSocketSpawner.py, 932 bytes (added by stefanomasini, 10 years ago)
Line 
1
2import sys
3from twisted.internet import protocol
4from twisted.internet import reactor
5
6class MyPP(protocol.ProcessProtocol):
7    def __init__(self, verses):
8        self.verses = verses
9        self.data = ""
10    def connectionMade(self):
11        print "connectionMade!"
12        self.transport.closeStdin() # tell them we're done
13    def outReceived(self, data):
14        self.data = self.data + data
15    def errReceived(self, data):
16        self.data = self.data + data
17    def processEnded(self, status_object):
18        print "processEnded, status %d" % status_object.value.exitCode
19        print "quitting"
20        print self.data
21        reactor.stop()
22
23def starter():
24    pp = MyPP(10)
25    reactor.spawnProcess(pp, sys.executable, [sys.executable, "openSocketChild.py"], {})
26
27reactor.callLater(0, starter)
28
29from twisted.application import service
30application = service.Application('pydapserver')
31