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`
pull/25/head
Jan Pochyla 8 years ago committed by Pavol Rusnak
parent 02b13af526
commit 70110187cc
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

@ -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…
Cancel
Save