Author: Antonio Cuni <anto.c...@gmail.com>
Branch: extradoc
Changeset: r3817:9541fc4c39ea
Date: 2011-07-01 14:58 +0200
http://bitbucket.org/pypy/extradoc/changeset/9541fc4c39ea/

Log:    exit more nicely than with an IOError/broken pipe

diff --git a/talk/iwtc11/benchmarks/image/magnify.py 
b/talk/iwtc11/benchmarks/image/magnify.py
--- a/talk/iwtc11/benchmarks/image/magnify.py
+++ b/talk/iwtc11/benchmarks/image/magnify.py
@@ -1,3 +1,6 @@
+#!/usr/bin/env python
+
+import errno
 from plain import Image
 from math import atan2, sqrt, sin, cos, ceil, floor
 
@@ -65,7 +68,13 @@
 
     start = start0 = time()
     for fcnt, img in enumerate(mplayer(MyImage, fn)):
-        view(magnify(img))
+        try:
+            view(magnify(img))
+        except IOError, e:
+            if e.errno != errno.EPIPE:
+                raise
+            print 'Exiting'
+            break
         print 1.0 / (time() - start), 'fps, ', (fcnt-2) / (time() - start0), 
'average fps'
         start = time()
         if fcnt==2:
diff --git a/talk/iwtc11/benchmarks/image/sobel.py 
b/talk/iwtc11/benchmarks/image/sobel.py
--- a/talk/iwtc11/benchmarks/image/sobel.py
+++ b/talk/iwtc11/benchmarks/image/sobel.py
@@ -1,3 +1,4 @@
+import errno
 from noborder import NoBorderImagePadded
 from math import sqrt
 
@@ -78,8 +79,15 @@
         #view(img)
         #sobeldx(img)
         #view(uint8(sobel_magnitude(img)))
-        view(sobel_magnitude_uint8(img))
         #sobel_magnitude_uint8(img)
+        try:
+            view(sobel_magnitude_uint8(img))
+        except IOError, e:
+            if e.errno != errno.EPIPE:
+                raise
+            print 'Exiting'
+            break
+
         print 1.0 / (time() - start), 'fps, ', (fcnt-2) / (time() - start0), 
'average fps'
         start = time()
         if fcnt==2:
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to