mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 15:38:11 +00:00
overload __iter__ in loop.Wait
This will automatically exit child tasks in case of close() or throw() on the waiting task, but only if run through `await` or `yield from`
This commit is contained in:
parent
02b13af526
commit
70110187cc
@ -15,8 +15,4 @@ async def animate_logo():
|
||||
|
||||
|
||||
async def layout_homescreen():
|
||||
wait = loop.Wait([swipe_to_rotate(), animate_logo()])
|
||||
try:
|
||||
await wait
|
||||
finally:
|
||||
wait.exit()
|
||||
await loop.Wait([swipe_to_rotate(), animate_logo()])
|
||||
|
@ -194,3 +194,10 @@ class Wait(Syscall):
|
||||
if self.exit_others:
|
||||
self.exit()
|
||||
schedule_task(self.callback, result)
|
||||
|
||||
def __iter__(self):
|
||||
try:
|
||||
return (yield self)
|
||||
except:
|
||||
self.exit()
|
||||
raise
|
||||
|
Loading…
Reference in New Issue
Block a user