1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-18 12:28:09 +00:00

src/trezor/wire: clean up after workflows

This commit is contained in:
Jan Pochyla 2018-04-03 20:38:36 +02:00
parent b38d6870eb
commit 04680f4bbf

View File

@ -3,6 +3,7 @@ import protobuf
from trezor import log
from trezor import loop
from trezor import messages
from trezor import utils
from trezor import workflow
from . import codec_v1
@ -119,12 +120,14 @@ async def session_handler(iface, sid):
except KeyError:
handler, args = unexpected_msg, ()
m = utils.unimport_begin()
w = handler(ctx, reader, *args)
try:
workflow.onstart(w)
await w
finally:
workflow.onclose(w)
utils.unimport_end(m)
except UnexpectedMessageError as exc:
# retry with opened reader from the exception