diff --git a/giambio/core.py b/giambio/core.py index 237c76b..1715271 100644 --- a/giambio/core.py +++ b/giambio/core.py @@ -644,6 +644,8 @@ class AsyncScheduler: self.debugger.on_task_exit(task) if task.last_io: self.io_release_task(task) + if task in self.suspended: + self.suspended.remove(task) # If the pool has finished executing or we're at the first parent # task that kicked the loop, we can safely reschedule the parent(s) if task.pool is None: @@ -651,6 +653,8 @@ class AsyncScheduler: if task.pool.done(): self.reschedule_joiners(task) elif task.exc: + if task in self.suspended: + self.suspended.remove(task) task.status = "crashed" if task.exc.__traceback__: # TODO: We might want to do a bit more complex traceback hacking to remove any extra diff --git a/tests/chatroom_client.py b/tests/chatroom_client.py index 80ac22e..a1e28d2 100644 --- a/tests/chatroom_client.py +++ b/tests/chatroom_client.py @@ -8,6 +8,7 @@ async def sender(sock: giambio.socket.AsyncSocket, q: giambio.Queue): while True: await sock.send_all(b"yo") await q.put((0, "")) + await giambio.sleep(1) async def receiver(sock: giambio.socket.AsyncSocket, q: giambio.Queue): diff --git a/tests/timeout.py b/tests/timeout.py index 01d4e50..dc1cc5f 100644 --- a/tests/timeout.py +++ b/tests/timeout.py @@ -12,11 +12,11 @@ async def main(): start = giambio.clock() try: async with giambio.with_timeout(12) as pool: - await pool.spawn(child, 7) # This will complete - await giambio.sleep(2) # This will make the code below wait 2 seconds + await pool.spawn(child, 7) # This will complete + await giambio.sleep(2) # This will make the code below wait 2 seconds await pool.spawn(child, 15) # This will not complete - await giambio.sleep(50) - await child(20) # Neither will this + await child(20) # Neither will this + await giambio.sleep(50) # Nor this except giambio.exceptions.TooSlowError: print("[main] One or more children have timed out!") print(f"[main] Children execution complete in {giambio.clock() - start:.2f} seconds")