summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Blecker <matthewb@chromium.org>2018-10-12 11:45:36 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-10-18 10:55:36 -0700
commita1d66fd618cbafd6e698fa56590eec7a22923a08 (patch)
tree764e7f4e59abc472e7ab8c72f6e4443bcd285d2e
parent58d06c4e513e035f15710e7f176fa8e39bcda5e6 (diff)
downloadchrome-ec-a1d66fd618cbafd6e698fa56590eec7a22923a08.tar.gz
ec3po: Update threadproc_shim.py to use threading-oriented implementations.
This migrates ec3po from using subprocesses to threads. BRANCH=none BUG=b:79684405 CQ-DEPEND=CL:1279118, CL:1281997, CL:1282265 TEST=With a servo_micro connected to an octopus_ite, functionality involving the EC console continues to work. I tested dut-control ec_uart_pty, servo_console_pty (both tested with minicom), dut_i2c_mux, enable_ite_dfu, get_ite_chipid commands. Additionally, servod shutdown via either ctrl+c or SIGTERM still happens correctly, without any delay, leftover processes, or tracebacks. Change-Id: Ib59aa83400ee982a5cc4d1d9d1609197a1145514 Signed-off-by: Matthew Blecker <matthewb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1279145 Tested-by: Ruben Rodriguez Buchillon <coconutruben@chromium.org> Reviewed-by: Ruben Rodriguez Buchillon <coconutruben@chromium.org>
-rw-r--r--util/ec3po/threadproc_shim.py16
1 files changed, 7 insertions, 9 deletions
diff --git a/util/ec3po/threadproc_shim.py b/util/ec3po/threadproc_shim.py
index 5edbf0dd89..d5f5d19245 100644
--- a/util/ec3po/threadproc_shim.py
+++ b/util/ec3po/threadproc_shim.py
@@ -12,10 +12,6 @@ This contains only the multiprocessing objects or threading-oriented equivalents
that are actually in use by ec3po. There is no need for further functionality,
because this shim will be deleted after the migration is complete.
-TODO(b/79684405): After both platform/ec/ and third_party/hdctools/ sides of
-ec3po have been updated to use this library, replace the multiprocessing
-implementations with threading-oriented equivalents.
-
TODO(b/79684405): Stop using multiprocessing.Pipe. The
multiprocessing.Connection objects it returns serialize and deserialize objects
(via Python pickling), which is necessary for sending them between processes,
@@ -37,14 +33,12 @@ wait until after completing the TODO above to stop using multiprocessing.Pipe!
"""
# Imports to bring objects into this namespace for users of this module.
+from Queue import Queue
from multiprocessing import Pipe
-from multiprocessing import Process as ThreadOrProcess
-from multiprocessing import Queue
-from multiprocessing import Value
+from threading import Thread as ThreadOrProcess
# True if this module has ec3po using subprocesses, False if using threads.
-# TODO(b/79684405): Change to False when switching to threading.
-USING_SUBPROCS = True
+USING_SUBPROCS = False
def _DoNothing():
@@ -66,3 +60,7 @@ def DoIf(subprocs=_DoNothing, threads=_DoNothing):
Either the subprocs or threads argument will be returned.
"""
return subprocs if USING_SUBPROCS else threads
+
+
+def Value(ctype, *args):
+ return ctype(*args)