diff options
author | Andre McCurdy <armccurdy@gmail.com> | 2017-08-25 13:36:30 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-08-27 22:30:06 +0100 |
commit | 0063ae931082de11e8c45f4ea3ef5a66b5515159 (patch) | |
tree | f66bdf092a5803ddf6d7c594f16ef15217f8dd7d /meta | |
parent | b5db9f05a184a75bebeed7de0de2a0031035f495 (diff) | |
download | poky-0063ae931082de11e8c45f4ea3ef5a66b5515159.tar.gz |
terminal.py: avoid 100% cpu while waiting for phonehome pid file
Some of the less common terminal types haven't been tested with the
recent phonehome pid file changes and there may be error cases where
the pid file is never created.
(From OE-Core rev: 6b0cf568e9fbe28fb6e7b17f4ad92348d33e2bf4)
Signed-off-by: Andre McCurdy <armccurdy@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/lib/oe/terminal.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/meta/lib/oe/terminal.py b/meta/lib/oe/terminal.py index 3c6220dfce..714772f741 100644 --- a/meta/lib/oe/terminal.py +++ b/meta/lib/oe/terminal.py | |||
@@ -221,6 +221,7 @@ def spawn(name, sh_cmd, title=None, env=None, d=None): | |||
221 | # to a file using a "phonehome" wrapper script, then monitor the pid | 221 | # to a file using a "phonehome" wrapper script, then monitor the pid |
222 | # until it exits. | 222 | # until it exits. |
223 | import tempfile | 223 | import tempfile |
224 | import time | ||
224 | pidfile = tempfile.NamedTemporaryFile(delete = False).name | 225 | pidfile = tempfile.NamedTemporaryFile(delete = False).name |
225 | try: | 226 | try: |
226 | sh_cmd = "oe-gnome-terminal-phonehome " + pidfile + " " + sh_cmd | 227 | sh_cmd = "oe-gnome-terminal-phonehome " + pidfile + " " + sh_cmd |
@@ -232,13 +233,13 @@ def spawn(name, sh_cmd, title=None, env=None, d=None): | |||
232 | raise ExecutionError(sh_cmd, pipe.returncode, output) | 233 | raise ExecutionError(sh_cmd, pipe.returncode, output) |
233 | 234 | ||
234 | while os.stat(pidfile).st_size <= 0: | 235 | while os.stat(pidfile).st_size <= 0: |
236 | time.sleep(0.01) | ||
235 | continue | 237 | continue |
236 | with open(pidfile, "r") as f: | 238 | with open(pidfile, "r") as f: |
237 | pid = int(f.readline()) | 239 | pid = int(f.readline()) |
238 | finally: | 240 | finally: |
239 | os.unlink(pidfile) | 241 | os.unlink(pidfile) |
240 | 242 | ||
241 | import time | ||
242 | while True: | 243 | while True: |
243 | try: | 244 | try: |
244 | os.kill(pid, 0) | 245 | os.kill(pid, 0) |