More TODOS

This commit is contained in:
nocturn9x 2020-03-21 12:09:11 +00:00
parent 54c36c08be
commit e8bef73f36
2 changed files with 7 additions and 4 deletions

View File

@ -1,6 +1,4 @@
import giambio
loop = giambio.EventLoop()
"""
@ -42,8 +40,11 @@ async def count(stop, step=1):
async def main():
print("Spawning countdown immediately, scheduling count for 2 secs from now")
task = loop.spawn(countdown(8))
task1 = loop.schedule(count(12, 2), 2)
task1 = loop.schedule(count(8, 2), 2)
await giambio.sleep(2) # Wait before cancelling
await task.cancel() # Cancel the task
# await task.cancel() # Cancel the task
result = await task1.join() # Joining multiple tasks still causes problems
# result1 = await task.join()
print("All done")
loop.start(main)

View File

@ -53,6 +53,8 @@ class EventLoop:
self.to_run.extend(self.joined.pop(self.running, ())) # Reschedules the parent task
except RuntimeError:
self.running.cancelled = True
self.to_run.extend(self.joined.pop(self.running, ())) # Reschedules the parent task
print(self.to_run)
except Exception as has_raised:
self.to_run.extend(self.joined.pop(self.running, ())) # Reschedules the parent task
if self.running.joined: # Let the join function handle the hassle of propagating the error