forked from M-Labs/artiq
master: cleaner shutdown
This commit is contained in:
parent
95ee6a4951
commit
5df8ffe08e
|
@ -108,12 +108,16 @@ class Scheduler:
|
||||||
else:
|
else:
|
||||||
self.queue_modified.clear()
|
self.queue_modified.clear()
|
||||||
self.periodic_modified.clear()
|
self.periodic_modified.clear()
|
||||||
|
t1 = asyncio.Task(self.queue_modified.wait())
|
||||||
|
t2 = asyncio.Task(self.periodic_modified.wait())
|
||||||
|
try:
|
||||||
done, pend = yield from asyncio.wait(
|
done, pend = yield from asyncio.wait(
|
||||||
[
|
[t1, t2],
|
||||||
self.queue_modified.wait(),
|
|
||||||
self.periodic_modified.wait()
|
|
||||||
],
|
|
||||||
timeout=next_periodic,
|
timeout=next_periodic,
|
||||||
return_when=asyncio.FIRST_COMPLETED)
|
return_when=asyncio.FIRST_COMPLETED)
|
||||||
|
except:
|
||||||
|
t1.cancel()
|
||||||
|
t2.cancel()
|
||||||
|
raise
|
||||||
for t in pend:
|
for t in pend:
|
||||||
t.cancel()
|
t.cancel()
|
||||||
|
|
Loading…
Reference in New Issue