diff options
author | yuhuan.yang <yuhuan.yang@123.com> | 2017-05-22 21:55:23 +0800 |
---|---|---|
committer | xiaojuan.mao <xiaojuan.mao@samsung.com> | 2017-07-13 11:23:04 +0800 |
commit | 78988abee759659de6367eed75c7d671ac39ea24 (patch) | |
tree | 455c0c886a812cfe3027fd1e9ffb8e2c597c0cf5 | |
parent | 85ac4324ef3f5555752d36ce4a9dbbcdc654b689 (diff) | |
download | mic-78988abee759659de6367eed75c7d671ac39ea24.tar.gz mic-78988abee759659de6367eed75c7d671ac39ea24.tar.bz2 mic-78988abee759659de6367eed75c7d671ac39ea24.zip |
Solve mic hang issue, add timeout to show failure.
Change-Id: If1d554455ff6d159789cd0aebae88ed3bdf2451b
-rwxr-xr-x | mic/imager/baseimager.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/mic/imager/baseimager.py b/mic/imager/baseimager.py index 0230424..26104c8 100755 --- a/mic/imager/baseimager.py +++ b/mic/imager/baseimager.py @@ -30,13 +30,15 @@ import json from datetime import datetime import rpm - +import time from mic import kickstart from mic import msger, __version__ as VERSION from mic.utils.errors import CreatorError, Abort from mic.utils import misc, grabber, runner, fs_related as fs from mic.chroot import kill_proc_inchroot from mic.archive import get_archive_suffixes +#post script max run time +MAX_RUN_TIME = 120 class BaseImageCreator(object): """Installs a system to a chroot directory. @@ -1158,6 +1160,7 @@ class BaseImageCreator(object): preexec = self._chroot script = "/tmp/" + os.path.basename(path) + start_time = time.time() try: try: p = subprocess.Popen([s.interp, script], @@ -1167,6 +1170,9 @@ class BaseImageCreator(object): stderr = subprocess.STDOUT) while p.poll() == None: msger.info(p.stdout.readline().strip()) + end_time = time.time() + if (end_time - start_time)/60 > MAX_RUN_TIME: + raise CreatorError("Your post script is executed more than "+MAX_RUN_TIME+"mins, please check it!") except OSError, (err, msg): raise CreatorError("Failed to execute %%post script " "with '%s' : %s" % (s.interp, msg)) |