jamadden/trollius

Future._copy_state does not copy the traceback

Opened this issue · 1 comments

Future._copy_state does not copy the traceback and causes the following test to fail in python 2, while passing in python 3:

import pytest
try:
    import asyncio
except ImportError:
    import trollius as asyncio

def add(a, b):
    raise RuntimeError("Fail!")  # I should be in the traceback
    return a + b

def test():
    loop = asyncio.get_event_loop()
    coro = loop.run_in_executor(None, add, 1, 2)
    with pytest.raises(RuntimeError) as excinfo:
        loop.run_until_complete(coro)
    statement = str(excinfo.traceback[-1].statement)
    assert "I should be in the traceback" in statement

I guess copying the traceback in _copy_state is a bit annoying since concurrent.futures uses Future.exception_info/set_exception_info and asyncio uses Future.exception/_get_exception_tb/_set_exception_with_tb.

Thank you for the report. Unfortunately this project is not maintained and not expecting to make any functional changes.