def _eintr_retry(func, *args): """restart a system call interrupted by EINTR""" while True: try: return func(*args) except OSError as e: if e.args[0] != errno.EINTR: raise