[PATCH 5 of 7] get-with-headers: handle broken pipes (py3)

timeless timeless at fmr.im
Wed May 11 01:20:27 EDT 2016


# HG changeset patch
# User timeless <timeless at mozdev.org>
# Date 1462561565 0
#      Fri May 06 19:06:05 2016 +0000
# Node ID 67542cf802e8669a1c954c3066f468fe3ae6ba0e
# Parent  3572b4c6d058583392f19d3c397804bc37e98a7b
# EXP-Topic runtests
# Available At bb://timeless/mercurial-crew
#              hg pull bb://timeless/mercurial-crew -r 67542cf802e8
get-with-headers: handle broken pipes (py3)

http://bugs.python.org/issue11380,#msg248579

indicates a recommended sequence for handling shutdown

diff -r 3572b4c6d058 -r 67542cf802e8 tests/get-with-headers.py
--- a/tests/get-with-headers.py	Wed May 11 01:56:59 2016 +0000
+++ b/tests/get-with-headers.py	Fri May 06 19:06:05 2016 +0000
@@ -69,10 +69,22 @@
 
     return response.status
 
-status = request(sys.argv[1], sys.argv[2], sys.argv[3:])
-if twice:
+try:
     status = request(sys.argv[1], sys.argv[2], sys.argv[3:])
+    if twice:
+        status = request(sys.argv[1], sys.argv[2], sys.argv[3:])
 
-if 200 <= status <= 305:
-    sys.exit(0)
+    if 200 <= status <= 305:
+        sys.exit(0)
+finally:
+    try:
+        sys.stdout.flush()
+    finally:
+        try:
+            sys.stdout.close()
+        finally:
+            try:
+                sys.stderr.flush()
+            finally:
+                sys.stderr.close()
 sys.exit(1)


More information about the Mercurial-devel mailing list