summaryrefslogtreecommitdiff
path: root/util/ec3po
diff options
context:
space:
mode:
authorMatthew Blecker <matthewb@chromium.org>2018-10-11 13:42:49 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-10-12 18:55:00 -0700
commitbcc0bcefa5aef4da99f80151c157437704d538c9 (patch)
tree3bdcd9abfe4b44e4f365692d0da14076c763ae8a /util/ec3po
parent91fd6c54d03f919d97ca4151191eb7a9a11f85dc (diff)
downloadchrome-ec-bcc0bcefa5aef4da99f80151c157437704d538c9.tar.gz
ec3po: Remove sys.exit() call from the end of StartLoop() functions.
This removes explicit process exit() from both console and interpeter ec3po StartLoop() functions. Use of exit() is incompatible with running these functions in threads instead of subprocesses. This should be a no-op, since letting execution finish in Python should be equivalent to sys.exit(). Since exit() in the finally: block effectively suppressed exceptions, the same behavior is now achieved in interpreter.StartLoop() by use of an except: block, same as console.StartLoop() already had. BRANCH=none BUG=b:79684405 TEST=All servod processes still exit promptly and without printing tracebacks, upon either ctrl+c from console where servod launched, or from SIGTERM to parent servod process. I confirmed that the new code was in use by adding an extra logging line on each of ec3po console and interpreter loop start (not present in uploaded patch). Testing performed with a servo_micro attached to an octopus_ite. Change-Id: Ie92610de88fea78f6c50f5e49b9d0940f209cd92 Signed-off-by: Matthew Blecker <matthewb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1278085 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'util/ec3po')
-rwxr-xr-xutil/ec3po/console.py18
-rw-r--r--util/ec3po/interpreter.py12
2 files changed, 19 insertions, 11 deletions
diff --git a/util/ec3po/console.py b/util/ec3po/console.py
index 608e1b7cba..3657ceb20e 100755
--- a/util/ec3po/console.py
+++ b/util/ec3po/console.py
@@ -825,13 +825,13 @@ def StartLoop(console, command_active):
command_active: multiprocessing.Value indicating if servod owns
the console, or user owns the console. This prevents input collisions.
"""
- console.logger.debug('Console is being served on %s.', console.user_pty)
- console.logger.debug('Console master is on %s.', console.master_pty)
- console.logger.debug('Command interface is being served on %s.',
- console.interface_pty)
- console.logger.debug(console)
-
try:
+ console.logger.debug('Console is being served on %s.', console.user_pty)
+ console.logger.debug('Console master is on %s.', console.master_pty)
+ console.logger.debug('Command interface is being served on %s.',
+ console.interface_pty)
+ console.logger.debug(console)
+
# This checks for HUP to indicate if the user has connected to the pty.
ep = select.epoll()
ep.register(console.master_pty, select.EPOLLHUP)
@@ -907,10 +907,14 @@ def StartLoop(console, command_active):
while not console.oobm_queue.empty():
console.logger.debug('OOBM queue ready for reading.')
console.ProcessOOBMQueue()
+
except KeyboardInterrupt:
pass
+
+ # TODO(crbug.com/894870): Stop suppressing all exceptions.
except:
traceback.print_exc()
+
finally:
# Unregister poll.
ep.unregister(console.master_pty)
@@ -921,8 +925,6 @@ def StartLoop(console, command_active):
os.close(console.master_pty)
os.close(console.interface_pty)
console.logger.debug('Exit ec3po console loop for %s', console.user_pty)
- # Exit.
- sys.exit(0)
def main(argv):
diff --git a/util/ec3po/interpreter.py b/util/ec3po/interpreter.py
index 9a0880f49c..9af5a67dd9 100644
--- a/util/ec3po/interpreter.py
+++ b/util/ec3po/interpreter.py
@@ -20,7 +20,6 @@ import logging
import os
import Queue
import select
-import sys
COMMAND_RETRIES = 3 # Number of attempts to retry a command.
@@ -408,11 +407,18 @@ def StartLoop(interp):
if obj is interp.ec_uart_pty:
interp.SendCmdToEC()
+ except KeyboardInterrupt:
+ pass
+
+ # TODO(crbug.com/894870): Stop suppressing all exceptions.
+ except:
+ traceback.print_exc()
+
finally:
# Close pipes.
interp.cmd_pipe.close()
interp.dbg_pipe.close()
# Close file descriptor.
interp.ec_uart_pty.close()
- # Exit.
- sys.exit(0)
+ interp.logger.debug('Exit ec3po interpreter loop for %s',
+ interp.ec_uart_pty_name)