[Twisted-Python] Re: [Twisted-commits] r16513 - fix buggy test, set binary mode on stdin/stdout

Jean-Paul Calderone exarkun at divmod.com
Sat Apr 1 21:00:01 MST 2006


On Fri, 31 Mar 2006 23:26:35 -0700, Glyph Lefkowitz <glyph at wolfwood.twistedmatrix.com> wrote:
>Author: glyph
>Date: Fri Mar 31 23:26:32 2006
>New Revision: 16513
>
>Modified:
>   branches/transtdio-1553/twisted/internet/_pollingfile.py
>   branches/transtdio-1553/twisted/internet/_win32stdio.py
>   branches/transtdio-1553/twisted/test/stdio_test_producer.py
>   branches/transtdio-1553/twisted/test/test_stdio.py
>Log:
>fix buggy test, set binary mode on stdin/stdout
>
> [snip]
>
>Modified: branches/transtdio-1553/twisted/test/stdio_test_producer.py
>==============================================================================
>--- branches/transtdio-1553/twisted/test/stdio_test_producer.py	(original)
>+++ branches/transtdio-1553/twisted/test/stdio_test_producer.py	Fri Mar 31 23:26:32 2006
>@@ -13,22 +13,28 @@
> from twisted.internet import stdio, protocol, reactor
> from twisted.python import log
>
>-
> class ProducerChild(protocol.Protocol):
>     _paused = False
>+    buf = ''
>
>     def connectionLost(self, reason):
>-        reactor.stop()
>+        log.msg("*****OVER*****")
>+        reactor.callLater(1, reactor.stop)
>+        # reactor.stop()

This looks pretty sketchy.

>
>
>     def dataReceived(self, bytes):
>+        self.buf += bytes
>         if self._paused:
>-            log.startLogging(sys.stdout)
>+            log.startLogging(sys.stderr)
>             log.msg("dataReceived while transport paused!")
>             self.transport.loseConnection()
>         else:
>             self.transport.write(bytes)
>-            self.pause()
>+            if self.buf.endswith('\n0\n'):
>+                self.transport.loseConnection()
>+            else:
>+                self.pause()

So does this.  Why isn't it cool for the parent process to drop the connection?

Jean-Paul




More information about the Twisted-Python mailing list