dabeaz / curio

Good Curio!
Other
4.02k stars 241 forks source link

Caught exception is printed to stdout #236

Closed povilasb closed 6 years ago

povilasb commented 6 years ago
#  curio==0.8

import curio

async def err():
    raise Exception('ooops')

async def main():
    task = await curio.spawn(err)

    try:
        await task.join()
    except:
        pass
    print('Proceeding')

curio.run(main)

This little snippet outputs me:

Task 3 crashed
Traceback (most recent call last):
  File "/home/povilas/projects/pyigd/pyenv/lib/python3.6/site-packages/curio/kernel.py", line 826, in _run_coro
    trap = current._send(current.next_value)
  File "/home/povilas/projects/pyigd/pyenv/lib/python3.6/site-packages/curio/task.py", line 96, in _task_runner
    return await coro
  File "/home/povilas/projects/pyigd/igd/__main__.py", line 7, in err
    raise Exception('ooops')
Exception: ooops
Proceeding

Since I catch the exception, I'd expect no output from it.

dabeaz commented 6 years ago

The output of uncaught exceptions is controlled by a debug option. If you use run(coro, debug=None), the output should disappear.

dabeaz commented 6 years ago

Will note that I'm going to check into the output of this. I seem to recall a recent modification to not print exceptions if caught/joined. That might not be in the main release yet though.

povilasb commented 6 years ago

curio.run(main, debug=None) works with 0.8 thanks :)