Skip to content

Future exception was never retrieved problem when use with decorator in v2.0 #39

Description

@shadowlinyf

how to reproduce the problem:

@Memoize(10000, timedelta(seconds=100))
async def foo_a(a:int) -> int:
    raise Exception("test")
    return a

@foo_a.key
def _(a:int) -> str:
    return f"a:{a}"

async def main():
    await foo_a(1)

if __name__ == "__main__":
    asyncio.run(main())

result:

Future exception was never retrieved
future: <Future finished exception=Exception('test')>
Traceback (most recent call last):
  File "\lib\site-packages\theine\theine.py", line 79, in __await__
    result = yield from self.awaitable.__await__()
  File "\test\theine_demo.py", line 20, in foo_a
    raise Exception("test")
Exception: test
Traceback (most recent call last):
  File "\test\theine_demo.py", line 38, in <module>
    asyncio.run(main())
  File "\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "\lib\asyncio\base_events.py", line 649, in run_until_complete
    return future.result()
  File "\test\theine_demo.py", line 29, in main
    await foo_a(1)
  File "\lib\site-packages\theine\theine.py", line 90, in __await__
    raise e
  File "\lib\site-packages\theine\theine.py", line 79, in __await__
    result = yield from self.awaitable.__await__()
  File "\testt\theine_demo.py", line 20, in foo_a
    raise Exception("test")
Exception: test

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions