FIX: Removing coroutine in a heap that contiains tuples, not coroutines.

This commit is contained in:
Julien Palard 2020-03-08 00:01:13 +01:00
parent 7b07f9b41e
commit 1a8919b239
1 changed files with 9 additions and 5 deletions

View File

@ -295,9 +295,11 @@ something usefull to the coroutine manager, like an ETA before calling
if exec_at > datetime.now():
sleep((exec_at - datetime.now()).total_seconds())
try:
heapq.heappush(coros, (coro.send(None), coro))
exec_at = coro.send(None)
except StopIteration as stop:
coros.remove(coro)
pass
else:
heapq.heappush(coros, (exec_at, coro))
print(measured_coro_manager(tum(), pak()))
@ -451,10 +453,12 @@ From this point we can go further by playing with the [dining philosophers probl
if exec_at > now:
sleep((exec_at - now).total_seconds())
try:
heapq.heappush(coros, (coro.send(None), i, coro))
i += 1
exec_at = coro.send(None)
except StopIteration as stop:
coros.remove(coro)
pass
else:
i += 1
heapq.heappush(coros, (exec_at, i, coro))
table = Table()
measured_coro_manager(check_life(table.philosophers),