mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-15 19:08:07 +00:00
core/workflow: properly reset the default task global
This commit is contained in:
parent
6d1a315b0e
commit
29cca614f0
@ -54,13 +54,21 @@ def start_default(constructor: Callable[[], loop.Task]) -> None:
|
|||||||
if not default_task:
|
if not default_task:
|
||||||
default_constructor = constructor
|
default_constructor = constructor
|
||||||
default_task = constructor()
|
default_task = constructor()
|
||||||
loop.schedule(default_task)
|
|
||||||
|
# Schedule the default task. Because the task can complete on its own,
|
||||||
|
# we need to reset the `default_task` global in a finalizer.
|
||||||
|
loop.schedule(default_task, None, None, _finalize_default)
|
||||||
|
|
||||||
|
|
||||||
def close_default() -> None:
|
def close_default() -> None:
|
||||||
"""Explicitly close the default workflow task."""
|
"""Explicitly close the default workflow task."""
|
||||||
|
if default_task:
|
||||||
|
# We let the `_finalize_default` reset the global.
|
||||||
|
loop.close(default_task)
|
||||||
|
|
||||||
|
|
||||||
|
def _finalize_default(task, value) -> None:
|
||||||
global default_task
|
global default_task
|
||||||
|
|
||||||
if default_task:
|
if default_task is task:
|
||||||
loop.close(default_task)
|
|
||||||
default_task = None
|
default_task = None
|
||||||
|
Loading…
Reference in New Issue
Block a user