python-trio / python-trio/trio

Add documentation on interpreting Trio tracebacks

Open
#798 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

docs user happiness
Dominant language
Python
Stars
7.3k
Forks
431
Avg merge
2d 17h
Merged PRs (30d)
6

Description

Perhaps this is a general Python issue, but it's rather confusing that the last line of a nursery block appears in exception traces regardless of the line being reached. Seen with Python 3.6 / Trio 0.9.0:

import trio

async def async_main():
    async with trio.open_nursery() as nursery:
        @nursery.start_soon
        async def raiser():
            await trio.sleep(1)
            raise Exception('boo')

        await trio.sleep_forever()
        assert False
        print("Last line of nursery block")

try:
    trio.run(async_main)
except KeyboardInterrupt:
    pass
Traceback (most recent call last):
  File "trace_mystery.py", line 17, in <module>
    trio.run(async_main)
  File "/.../trio/_core/_run.py", line 1337, in run
    raise runner.main_task_outcome.error
  File "trace_mystery.py", line 13, in async_main
    print("Last line of nursery block")                              <--- ????
  File "/.../trio/_core/_run.py", line 397, in __aexit__
    raise combined_error_from_nursery
  File "trace_mystery.py", line 9, in raiser
    raise Exception('boo')
Exception: boo

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reproduction in trace_mystery.py and compare its traceback with the referenced paths in trio/_core/_run.py. Document how to interpret the nursery traceback, including the displayed line in async_main and the raiser location, and use the example to check that the explanation matches the reported output.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.