Skip to contentSkip to conversation

terminal.py: avoid 100% cpu while waiting for phonehome pid file

PATCH New Andre McCurdy 1 participant 3 messages Aug 25, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 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.

---
 meta/lib/oe/terminal.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
meta/lib/oe/terminal.py +2 -1
index 3c6220d..714772f 100644
@@ -221,6 +221,7 @@ def spawn(name, sh_cmd, title=None, env=None, d=None):
     # to a file using a "phonehome" wrapper script, then monitor the pid
     # until it exits.
     import tempfile
+    import time
     pidfile = tempfile.NamedTemporaryFile(delete = False).name
     try:
         sh_cmd = "oe-gnome-terminal-phonehome " + pidfile + " " + sh_cmd
@@ -232,13 +233,13 @@ def spawn(name, sh_cmd, title=None, env=None, d=None):
             raise ExecutionError(sh_cmd, pipe.returncode, output)
 
         while os.stat(pidfile).st_size <= 0:
+            time.sleep(0.01)
             continue
         with open(pidfile, "r") as f:
             pid = int(f.readline())
     finally:
         os.unlink(pidfile)
 
-    import time
     while True:
         try:
             os.kill(pid, 0)
Signature · 1 line
1.9.1
#1 lore raw

PATCH 2/3 terminal.py: fix devshell with mate-terminal

Without the --disable-factory option, mate-terminal fails to start with the error:

| There was an error creating the child process for this terminal
| Failed to execute child process "oe-gnome-terminal-phonehome" (No such file or directory)

The --disable-factory option was removed by:

http://git.openembedded.org/openembedded-core/commit/?id=e8dca725ed8211a874472300a3ed50e494039ab9

apparently based on an assuption that mate-terminal continues to track gnome-terminal since forking from it. However, based on the mate-terminal man page in the upstream master branch, the option is still supported:

https://github.com/mate-desktop/mate-terminal

---
 meta/lib/oe/terminal.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/lib/oe/terminal.py +1 -1
index 714772f..89ddb46 100644
@@ -65,7 +65,7 @@ class Gnome(XTerminal):
         XTerminal.__init__(self, sh_cmd, title, env, d)
 
 class Mate(XTerminal):
-    command = 'mate-terminal -t "{title}" -x {command}'
+    command = 'mate-terminal --disable-factory -t "{title}" -x {command}'
     priority = 2
 
 class Xfce(XTerminal):
Signature · 1 line
1.9.1
#2 lore raw

PATCH 3/3 terminal.py: add support for mate-terminal in check_terminal_version()

In reply to Andre McCurdy

Not currently used, but include for completeness.

---
 meta/lib/oe/terminal.py | 2 ++
 1 file changed, 2 insertions(+)
meta/lib/oe/terminal.py +2 -0
index 89ddb46..9eb19a2 100644
@@ -292,6 +292,8 @@ def check_terminal_version(terminalName):
             vernum = ver.split(' ')[-1]
         if ver.startswith('GNOME Terminal'):
             vernum = ver.split(' ')[-1]
+        if ver.startswith('MATE Terminal'):
+            vernum = ver.split(' ')[-1]
         if ver.startswith('tmux'):
             vernum = ver.split()[-1]
     return vernum
Signature · 1 line
1.9.1