Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Side by Side Diff: third_party/twisted_8_1/twisted/test/stdio_test_producer.py

Issue 12261012: Remove third_party/twisted_8_1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 # -*- test-case-name: twisted.test.test_stdio.StandardInputOutputTestCase.test_p roducer -*-
2 # Copyright (c) 2006-2007 Twisted Matrix Laboratories.
3 # See LICENSE for details.
4
5 """
6 Main program for the child process run by
7 L{twisted.test.test_stdio.StandardInputOutputTestCase.test_producer} to test
8 that process transports implement IProducer properly.
9 """
10
11 import sys
12
13 from twisted.internet import stdio, protocol
14 from twisted.python import log, reflect
15
16 class ProducerChild(protocol.Protocol):
17 _paused = False
18 buf = ''
19
20 def connectionLost(self, reason):
21 log.msg("*****OVER*****")
22 reactor.callLater(1, reactor.stop)
23 # reactor.stop()
24
25
26 def dataReceived(self, bytes):
27 self.buf += bytes
28 if self._paused:
29 log.startLogging(sys.stderr)
30 log.msg("dataReceived while transport paused!")
31 self.transport.loseConnection()
32 else:
33 self.transport.write(bytes)
34 if self.buf.endswith('\n0\n'):
35 self.transport.loseConnection()
36 else:
37 self.pause()
38
39
40 def pause(self):
41 self._paused = True
42 self.transport.pauseProducing()
43 reactor.callLater(0.01, self.unpause)
44
45
46 def unpause(self):
47 self._paused = False
48 self.transport.resumeProducing()
49
50
51 if __name__ == '__main__':
52 reflect.namedAny(sys.argv[1]).install()
53 from twisted.internet import reactor
54 stdio.StandardIO(ProducerChild())
55 reactor.run()
OLDNEW
« no previous file with comments | « third_party/twisted_8_1/twisted/test/stdio_test_loseconn.py ('k') | third_party/twisted_8_1/twisted/test/stdio_test_write.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698