mirror of https://github.com/nocturn9x/giambio.git
Fixed bug where suspended tasks would not be purged upon exiting
This commit is contained in:
parent
587fba2dad
commit
f38e508ef6
|
@ -644,6 +644,8 @@ class AsyncScheduler:
|
||||||
self.debugger.on_task_exit(task)
|
self.debugger.on_task_exit(task)
|
||||||
if task.last_io:
|
if task.last_io:
|
||||||
self.io_release_task(task)
|
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
|
# 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)
|
# task that kicked the loop, we can safely reschedule the parent(s)
|
||||||
if task.pool is None:
|
if task.pool is None:
|
||||||
|
@ -651,6 +653,8 @@ class AsyncScheduler:
|
||||||
if task.pool.done():
|
if task.pool.done():
|
||||||
self.reschedule_joiners(task)
|
self.reschedule_joiners(task)
|
||||||
elif task.exc:
|
elif task.exc:
|
||||||
|
if task in self.suspended:
|
||||||
|
self.suspended.remove(task)
|
||||||
task.status = "crashed"
|
task.status = "crashed"
|
||||||
if task.exc.__traceback__:
|
if task.exc.__traceback__:
|
||||||
# TODO: We might want to do a bit more complex traceback hacking to remove any extra
|
# TODO: We might want to do a bit more complex traceback hacking to remove any extra
|
||||||
|
|
|
@ -8,6 +8,7 @@ async def sender(sock: giambio.socket.AsyncSocket, q: giambio.Queue):
|
||||||
while True:
|
while True:
|
||||||
await sock.send_all(b"yo")
|
await sock.send_all(b"yo")
|
||||||
await q.put((0, ""))
|
await q.put((0, ""))
|
||||||
|
await giambio.sleep(1)
|
||||||
|
|
||||||
|
|
||||||
async def receiver(sock: giambio.socket.AsyncSocket, q: giambio.Queue):
|
async def receiver(sock: giambio.socket.AsyncSocket, q: giambio.Queue):
|
||||||
|
|
|
@ -15,8 +15,8 @@ async def main():
|
||||||
await pool.spawn(child, 7) # This will complete
|
await pool.spawn(child, 7) # This will complete
|
||||||
await giambio.sleep(2) # This will make the code below wait 2 seconds
|
await giambio.sleep(2) # This will make the code below wait 2 seconds
|
||||||
await pool.spawn(child, 15) # This will not complete
|
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:
|
except giambio.exceptions.TooSlowError:
|
||||||
print("[main] One or more children have timed out!")
|
print("[main] One or more children have timed out!")
|
||||||
print(f"[main] Children execution complete in {giambio.clock() - start:.2f} seconds")
|
print(f"[main] Children execution complete in {giambio.clock() - start:.2f} seconds")
|
||||||
|
|
Loading…
Reference in New Issue