hephex / asyncache

Helpers to use cachetools with async functions
MIT License
90 stars 12 forks source link

Not working in cythonized file #1

Closed alex-eri closed 1 year ago

alex-eri commented 3 years ago

Coro cached instead its result

Traceback (most recent call last):
  File "runner.py", line 4, in <module>
    asyncio.run(test.main())
  File "/usr/lib/python3.8/asyncio/runners.py", line 43, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "test.py", line 11, in main
    await test(0)
RuntimeError: cannot reuse already awaited coroutine

test in attachments

python setup.py build_ext --inplace
python runner.py 

test.zip

alex-eri commented 3 years ago

Without inspect.iscoroutinefunction(func) works fine. Seems cython make its regular function returning Future.

alex-eri commented 3 years ago

https://github.com/cython/cython/issues/3849 upstream bug

amin-nejad commented 2 years ago

Based on the linked issue and linked issues therein, inspect.iscoroutinefunction should just be replaced with asyncio.iscoroutinefunction

hephex commented 1 year ago

This should be fixed now