1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-27 01:48:17 +00:00

trezor/loop: add loop.close()

This commit is contained in:
Jan Pochyla 2017-10-10 15:32:43 +02:00
parent 9ea975d37d
commit 04acab723a
4 changed files with 11 additions and 6 deletions

View File

@ -451,7 +451,8 @@ class ConfirmState:
def kill(self) -> None: def kill(self) -> None:
if self.task is not None: if self.task is not None:
workflow.onclose(self.task) workflow.onclose(self.task)
self.task.close() loop.close(self.task)
self.task = None
async def confirm(self) -> None: async def confirm(self) -> None:
from trezor.ui.confirm import HoldToConfirmDialog from trezor.ui.confirm import HoldToConfirmDialog

View File

@ -65,6 +65,12 @@ def unpause(task):
_paused[iface].remove(task) _paused[iface].remove(task)
def close(task):
unschedule(task)
unpause(task)
task.close()
def run(): def run():
''' '''
Loop forever, stepping through scheduled tasks and awaiting I/O events Loop forever, stepping through scheduled tasks and awaiting I/O events
@ -259,9 +265,7 @@ class wait(Syscall):
def exit(self): def exit(self):
for task in self.scheduled: for task in self.scheduled:
if task not in self.finished: if task not in self.finished:
unpause(task) close(task)
unschedule(task)
task.close()
async def _wait(self, child): async def _wait(self, child):
try: try:

View File

@ -227,7 +227,7 @@ class SesssionSupervisor:
def close(self, sid): def close(self, sid):
if sid in self.handling_tasks: if sid in self.handling_tasks:
task = self.handling_tasks.pop(sid) task = self.handling_tasks.pop(sid)
task.close() loop.close(task)
def newsid(self): def newsid(self):
while True: while True:

View File

@ -26,7 +26,7 @@ def closedefault():
global default global default
if default: if default:
default.close() loop.close(default)
default = None default = None
log.debug(__name__, 'closedefault') log.debug(__name__, 'closedefault')