diff --git a/examples/test_examples.py b/examples/test_examples.py index 3e6b8200..ae88b087 100644 --- a/examples/test_examples.py +++ b/examples/test_examples.py @@ -3,6 +3,34 @@ from pyqtgraph import Qt from . import utils import itertools import pytest +import os, sys + + +# printing on travis ci frequently leads to "interrupted system call" errors. +# as a workaround, we overwrite the built-in print function (bleh) +if os.getenv('TRAVIS') is not None: + if sys.version_info[0] < 3: + import __builtin__ as builtins + else: + import builtins + + def flaky_print(*args): + """Wrapper for print that retries in case of IOError. + """ + count = 0 + while count < 5: + count += 1 + try: + orig_print(*args) + break + except IOError: + if count >= 5: + raise + pass + orig_print = builtins.print + builtins.print = flaky_print + print("Installed wrapper for flaky print.") + # apparently importlib does not exist in python 2.6... try: