# HG changeset patch # User Matt Harbison # Date 1497835913 14400 # Node ID 23b07333a8b2a143486f22ada1606a7d225793a8 # Parent 2851b24eecc483ce1546d63d155fa2e9250e3f44 tinyproxy: explicitly flush logged messages On Windows, output streams are buffered when redirected to a file, and TerminateProcess() apparently doesn't trigger a flush. This left test-http-proxy.t missing part of the last line when it cat'd proxy.log[1]. Flushing stderr is all that is needed (on py27 anyway). I originally flushed stdout too, but that added additional output to the log: $ cat proxy.log + Accept: $LOCALIP (localhost)\r (esc) + Serving HTTP on 0.0.0.0 port 20810 ...\r (esc) + connect to localhost:$HGPORT\r (esc) * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob) + bye\r (esc) + connect to localhost:$HGPORT\r (esc) * - - [*] "GET http://localhost:$HGPORT/?cmd=branchmap HTTP/1.1" - - x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) + bye\r (esc) + connect to localhost:$HGPORT\r (esc) * - - [*] "GET http://localhost:$HGPORT/?cmd=stream_out HTTP/1.1" - - x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) + bye\r (esc) + connect to localhost:$HGPORT\r (esc) ... [1] https://www.mercurial-scm.org/pipermail/mercurial-devel/2017-April/096987.html diff -r 2851b24eecc4 -r 23b07333a8b2 tests/tinyproxy.py --- a/tests/tinyproxy.py Sun Jun 18 22:46:56 2017 +0900 +++ b/tests/tinyproxy.py Sun Jun 18 21:31:53 2017 -0400 @@ -53,6 +53,8 @@ self.log_message('"%s" %s %s%s', self.requestline, str(code), str(size), ''.join([' %s:%s' % h for h in sorted(xheaders)])) + # Flush for Windows, so output isn't lost on TerminateProcess() + sys.stderr.flush() def _connect_to(self, netloc, soc): i = netloc.find(':')