Skip to content

Commit

Permalink
Doc update. Minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
dabeaz committed Mar 16, 2017
1 parent 9a9c20c commit 2aa0f72
Show file tree
Hide file tree
Showing 6 changed files with 419 additions and 470 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ install:

script:
- python3 -m pytest
- sphinx-build -nW -q -b html -b linkcheck -d docs/_build/doctrees docs docs/_build/html
- sphinx-build -q -b html -b linkcheck -d docs/_build/doctrees docs docs/_build/html
5 changes: 4 additions & 1 deletion curio/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,10 @@ async def _shutdown_tasks(tocancel):
self._shutdown_funcs = None

if ret_exc:
raise TaskError('Task Crashed') from ret_exc
if isinstance(ret_exc, TaskError):
raise ret_exc
else:
raise TaskError('Task Crashed') from ret_exc
else:
return ret_val

Expand Down
8 changes: 6 additions & 2 deletions curio/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,11 @@ async def _task_runner(self, coro):
finally:
if self._taskgroup:
await self._taskgroup._task_done(me)
if self.daemon:
self._taskgroup._task_discard(me)
me._joined = True


async def join(self):
'''
Wait for a task to terminate. Returns the return value (if any)
Expand Down Expand Up @@ -299,14 +302,14 @@ async def add_task(self, task):
else:
self._running.add(task)

async def spawn(self, coro, *args):
async def spawn(self, coro, *args, daemon=False):
'''
Spawn a new task into the task group.
'''
if self._closed:
raise RuntimeError('Task group is closed')

task = await spawn(coro, *args)
task = await spawn(coro, *args, daemon=daemon)
await self.add_task(task)
return task

Expand Down Expand Up @@ -387,6 +390,7 @@ async def __aenter__(self):
return self

async def __aexit__(self, ty, val, tb):
print("EXIT", len(self._running), len(self._finished))
if ty:
# Exception in the block itself. Cancel all running children
for task in self._running:
Expand Down
Loading

0 comments on commit 2aa0f72

Please sign in to comment.