From c254758c83996f81ef0c8984d5951305f424de56 Mon Sep 17 00:00:00 2001 From: Jan Pochyla Date: Mon, 2 Oct 2017 16:18:27 +0200 Subject: [PATCH] Revert "trezor/loop: optimization" This reverts commit cfa1705a88c5c5c274caede5fe3a056af090de81. In MicroPython, list.clear() does not memset the backing buffer, preventing the paused tasks from being garbage collected. --- src/trezor/loop.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/trezor/loop.py b/src/trezor/loop.py index d23318d8..69ea4784 100644 --- a/src/trezor/loop.py +++ b/src/trezor/loop.py @@ -53,7 +53,7 @@ def unschedule(task): def pause(task, iface): - tasks = _paused.get(iface) + tasks = _paused.get(iface, None) if tasks is None: tasks = _paused[iface] = [] tasks.append(task) @@ -94,11 +94,9 @@ def run(): if io.poll(_paused, msg_entry, delay): # message received, run tasks paused on the interface - msg_tasks = _paused.get(msg_entry[0]) - if msg_tasks is not None: - for task in msg_tasks: - _step(task, msg_entry[1]) - msg_tasks.clear() + msg_tasks = _paused.pop(msg_entry[0], ()) + for task in msg_tasks: + _step(task, msg_entry[1]) else: # timeout occurred, run the first scheduled task if _queue: