'Sleep until PIPE is readable or we timeout.
A readable PIPE means a signal occurred.'

def sleep(self):

    try:
        ready = select.select([self.PIPE[0]], [], [], 1.0)
        if (not ready[0]):
            return
        while os.read(self.PIPE[0], 1):
            pass
    except (select.error, OSError) as e:
        error_number = getattr(e, 'errno', e.args[0])
        if (error_number not in [errno.EAGAIN, errno.EINTR]):
            raise
    except KeyboardInterrupt:
        sys.exit()
