From d2d43235c9c89fdacb4da1260de3f3d9db41c60d Mon Sep 17 00:00:00 2001 From: nocturn9x Date: Sat, 4 Apr 2020 16:43:07 +0000 Subject: [PATCH] Many fixes, still exceptions do not propagate properly, but tasks are cancelled when a task dies --- experiment.py | 11 +++++------ giambio/.exceptions.py.swp | Bin 0 -> 1024 bytes giambio/abstractions.py | 17 +++++------------ giambio/core.py | 15 +++++++++------ giambio/util.py | 20 +++++++++++--------- 5 files changed, 30 insertions(+), 33 deletions(-) create mode 100644 giambio/.exceptions.py.swp diff --git a/experiment.py b/experiment.py index ccd2dec..b918202 100644 --- a/experiment.py +++ b/experiment.py @@ -10,7 +10,7 @@ What works and what does not (25th March 2020 20:35) - Join mechanism: V - Sleep mechanism: V - Cancellation mechanism: V -- Exception propagation: V +- Exception propagation: X - Concurrent I/O: V - Return values of coroutines: V - Scheduling tasks for future execution: V @@ -23,6 +23,8 @@ async def countdown(n): while n > 0: print(f"Down {n}") n -= 1 + if n <= 2: # Test an exception that triggers only sometimes + raise ValueError await giambio.sleep(1) print("Countdown over") return "Count DOWN over" @@ -44,16 +46,13 @@ async def count(stop, step=1): async def main(): - try: print("Spawning countdown immediately, scheduling count for 4 secs from now") async with giambio.TaskManager(loop) as manager: - task = manager.spawn(countdown(4)) + task = manager.spawn(countdown(8)) manager.schedule(count(8, 2), 4) - await task.cancel() for task, ret in manager.values.items(): print(f"Function '{task.coroutine.__name__}' at {hex(id(task.coroutine))} returned an object of type '{type(ret).__name__}': {repr(ret)}") - except: # TODO: Fix this, see above - pass + loop.start(main) diff --git a/giambio/.exceptions.py.swp b/giambio/.exceptions.py.swp new file mode 100644 index 0000000000000000000000000000000000000000..d9d6f91964d95433261cf4568bf1c1cf81d9dd0c GIT binary patch literal 1024 zcmYc?$V<%2S1{HyVn6}c%NQ7n^7Bhj1aWY3@{<#DGV+TFDNfH!%uUM7*H5iTPAw?O X%+D*