1
0
鏡像自 https://github.com/trezor/trezor-firmware.git synced 2025-07-18 20:48:18 +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:
Jan Pochyla 2016-09-25 15:55:08 +02:00 提交者 Pavol Rusnak
父節點 02b13af526
當前提交 70110187cc
沒有發現已知的金鑰在資料庫的簽署中
GPG 金鑰 ID: 91F3B339B9A02A3D
共有 2 個檔案被更改,包括 8 行新增5 行删除

查看文件

@ -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