-
Notifications
You must be signed in to change notification settings - Fork 46
Too Much Recursion when run through Fastapi #490
Open
Description
Issue type
Bug
How did you install PythonMonkey?
Installed from pip
OS platform and distribution
Linux Mint 22 x86_64
Python version (python --version)
3.12.2
PythonMonkey version (pip show pythonmonkey)
1.1.1
Bug Description
pm.eval always returns a too much recursion error when in a fastapi application and in an endpoint.
It works fine when run through fastapi as normal code not in an endpoint.
This bug persists when run with daphne instead of uvicorn.
Standalone code to reproduce the issue
import pythonmonkey as pm import fastapi app = fastapi.FastAPI( title="demo thingy to show the bug", ) @app.get("/") def get_data(): return {pm.eval('1+1')}
Relevant log output or backtrace
cbass@cbass-laptop:~/picleaner$ python -m uvicorn test2:app INFO: Started server process [100668] INFO: Waiting for application startup. INFO: Application startup complete. INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) INFO: 127.0.0.1:46362 - "GET / HTTP/1.1" 500 Internal Server Error ERROR: Exception in ASGI application Traceback (most recent call last): File "/home/cbass/.local/lib/python3.12/site-packages/uvicorn/protocols/http/httptools_impl.py", line 426, in run_asgi result = await app( # type: ignore[func-returns-value] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/cbass/.local/lib/python3.12/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in __call__ return await self.app(scope, receive, send) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/cbass/.pyenv/versions/3.12.2/lib/python3.12/site-packages/fastapi/applications.py", line 1054, in __call__ await super().__call__(scope, receive, send) File "/home/cbass/.pyenv/versions/3.12.2/lib/python3.12/site-packages/starlette/applications.py", line 112, in __call__ await self.middleware_stack(scope, receive, send) File "/home/cbass/.pyenv/versions/3.12.2/lib/python3.12/site-packages/starlette/middleware/errors.py", line 187, in __call__ raise exc File "/home/cbass/.pyenv/versions/3.12.2/lib/python3.12/site-packages/starlette/middleware/errors.py", line 165, in __call__ await self.app(scope, receive, _send) File "/home/cbass/.pyenv/versions/3.12.2/lib/python3.12/site-packages/starlette/middleware/exceptions.py", line 62, in __call__ await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) File "/home/cbass/.pyenv/versions/3.12.2/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app raise exc File "/home/cbass/.pyenv/versions/3.12.2/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app await app(scope, receive, sender) File "/home/cbass/.pyenv/versions/3.12.2/lib/python3.12/site-packages/starlette/routing.py", line 714, in __call__ await self.middleware_stack(scope, receive, send) File "/home/cbass/.pyenv/versions/3.12.2/lib/python3.12/site-packages/starlette/routing.py", line 734, in app await route.handle(scope, receive, send) File "/home/cbass/.pyenv/versions/3.12.2/lib/python3.12/site-packages/starlette/routing.py", line 288, in handle await self.app(scope, receive, send) File "/home/cbass/.pyenv/versions/3.12.2/lib/python3.12/site-packages/starlette/routing.py", line 76, in app await wrap_app_handling_exceptions(app, request)(scope, receive, send) File "/home/cbass/.pyenv/versions/3.12.2/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app raise exc File "/home/cbass/.pyenv/versions/3.12.2/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app await app(scope, receive, sender) File "/home/cbass/.pyenv/versions/3.12.2/lib/python3.12/site-packages/starlette/routing.py", line 73, in app response = await f(request) ^^^^^^^^^^^^^^^^ File "/home/cbass/.pyenv/versions/3.12.2/lib/python3.12/site-packages/fastapi/routing.py", line 301, in app raw_response = await run_endpoint_function( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/cbass/.pyenv/versions/3.12.2/lib/python3.12/site-packages/fastapi/routing.py", line 214, in run_endpoint_function return await run_in_threadpool(dependant.call, **values) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/cbass/.pyenv/versions/3.12.2/lib/python3.12/site-packages/starlette/concurrency.py", line 37, in run_in_threadpool return await anyio.to_thread.run_sync(func) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/cbass/.local/lib/python3.12/site-packages/anyio/to_thread.py", line 33, in run_sync return await get_asynclib().run_sync_in_worker_thread( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/cbass/.local/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 877, in run_sync_in_worker_thread return await future ^^^^^^^^^^^^ File "/home/cbass/.local/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 807, in run result = context.run(func, *args) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/cbass/picleaner/test2.py", line 8, in get_data return {pm.eval('1+1') } ^^^^^^^^^^^^^^ pythonmonkey.SpiderMonkeyError: InternalError: too much recursion
Additional info if applicable
I also ran into another bug (don't know if it's related) where you can't import pythonmonkey when running through the fastapi cli, but that's another ticket.
What branch of PythonMonkey were you developing on? (If applicable)
No response
Activity
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
- StatusBacklog