changeset 34944:bf2db35a6fe7 stable

test-static-http: flush access log per request It appears that stderr is fully buffered on Windows. # no-check-commit because of log_message() function
author Yuya Nishihara <yuya@tcha.org>
date Sun, 29 Oct 2017 17:53:52 +0900
parents 3423f7e2d287
children d2554ef04d26
files tests/dumbhttp.py
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/tests/dumbhttp.py	Sat Oct 28 17:23:52 2017 +0900
+++ b/tests/dumbhttp.py	Sun Oct 29 17:53:52 2017 +0900
@@ -26,12 +26,16 @@
 else:
     simplehttpserver = httpserver.httpserver
 
+class _httprequesthandler(httpserver.simplehttprequesthandler):
+    def log_message(self, format, *args):
+        httpserver.simplehttprequesthandler.log_message(self, format, *args)
+        sys.stderr.flush()
+
 class simplehttpservice(object):
     def __init__(self, host, port):
         self.address = (host, port)
     def init(self):
-        self.httpd = simplehttpserver(
-            self.address, httpserver.simplehttprequesthandler)
+        self.httpd = simplehttpserver(self.address, _httprequesthandler)
     def run(self):
         self.httpd.serve_forever()