]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
- Suppressed IOErrors which can raise when program output pipe
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 11 Mar 2014 00:30:03 +0000 (20:30 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 11 Mar 2014 00:30:03 +0000 (20:30 -0400)
is closed under a program like ``head``; however this only
works on Python 2.  On Python 3, there is not yet a known way to
suppress the BrokenPipeError warnings without prematurely terminating
the program via signals. fixes #160.
Added comments to http://bugs.python.org/issue11380 to see what the
status is on py3k.

alembic/util.py
docs/build/changelog.rst

index 26f7ac09bfdc174791e3782f67ef2e8c9218f450..9f035decde5345176c4481f2720bc6d2e9f71a1d 100644 (file)
@@ -140,7 +140,13 @@ def write_outstream(stream, *text):
         if not isinstance(t, binary_type):
             t = t.encode(encoding, 'replace')
         t = t.decode(encoding)
-        stream.write(t)
+        try:
+            stream.write(t)
+        except IOError:
+            # suppress "broken pipe" errors.
+            # no known way to handle this on Python 3 however
+            # as the exception is "ignored" (noisily) in TextIOWrapper.
+            break
 
 def coerce_resource_to_filename(fname):
     """Interpret a filename as either a filesystem location or as a package resource.
index 2c592ab34db9253fe5e9333cf87948ebd1317b32..f32bb9b360369d44bb197030f6ed9ee8169afaab 100644 (file)
@@ -5,6 +5,16 @@ Changelog
 .. changelog::
     :version: 0.6.4
 
+    .. change::
+      :tags: bug
+      :tickets: 160
+
+      Suppressed IOErrors which can raise when program output pipe
+      is closed under a program like ``head``; however this only
+      works on Python 2.  On Python 3, there is not yet a known way to
+      suppress the BrokenPipeError warnings without prematurely terminating
+      the program via signals.
+
     .. change::
       :tags: bug
       :tickets: 179