forked from M-Labs/artiq
1
0
Fork 0

master: cleaner shutdown

This commit is contained in:
Sebastien Bourdeauducq 2015-01-15 11:07:55 +08:00
parent 95ee6a4951
commit 5df8ffe08e
1 changed files with 11 additions and 7 deletions

View File

@ -108,12 +108,16 @@ class Scheduler:
else:
self.queue_modified.clear()
self.periodic_modified.clear()
done, pend = yield from asyncio.wait(
[
self.queue_modified.wait(),
self.periodic_modified.wait()
],
timeout=next_periodic,
return_when=asyncio.FIRST_COMPLETED)
t1 = asyncio.Task(self.queue_modified.wait())
t2 = asyncio.Task(self.periodic_modified.wait())
try:
done, pend = yield from asyncio.wait(
[t1, t2],
timeout=next_periodic,
return_when=asyncio.FIRST_COMPLETED)
except:
t1.cancel()
t2.cancel()
raise
for t in pend:
t.cancel()