X-Git-Url: https://code.grnet.gr/git/snf-image-creator/blobdiff_plain/63e1b902670d78f62cd75c1d154bcbd2fd6e15ae..fa65eda12290726b54998d7fe60a0448a4bc22d0:/image_creator/rsync.py diff --git a/image_creator/rsync.py b/image_creator/rsync.py index 16f3c63..08bc27a 100644 --- a/image_creator/rsync.py +++ b/image_creator/rsync.py @@ -107,8 +107,7 @@ class Rsync: self._out.success("%d" % total) - progress = self._out.Progress(total, "Copying %s files to %s" % - (slabel, dlabel)) + progress = self._out.Progress(total, "Copying files to %s" % dlabel) run = subprocess.Popen(cmd + [src, dest], shell=False, stdout=subprocess.PIPE, bufsize=0) try: @@ -124,12 +123,19 @@ class Rsync: progress.success('done') finally: - run.poll() - if run.returncode is None: - run.send_signal(signal.SIGHUP) + def handler(signum, frame): + run.terminate() + time.sleep(1) + run.poll() + if run.returncode is None: + run.kill() + run.wait() + + signal.signal(signal.SIGALRM, handler) + signal.alarm(2) run.communicate() + signal.alarm(0) if run.returncode != 0: raise FatalError("rsync failed") - # vim: set sta sts=4 shiftwidth=4 sw=4 et ai :