Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaks under concurrency when using gevent #11

Open
ddorian opened this issue Oct 16, 2024 · 0 comments
Open

Breaks under concurrency when using gevent #11

ddorian opened this issue Oct 16, 2024 · 0 comments

Comments

@ddorian
Copy link

ddorian commented Oct 16, 2024

When running concurrent requests to the flask app I get this error often. It goes away if I comment this line:
app.teardown_appcontext(_close_async_sessions).

Debugging middleware caught exception in streamed response at a point where response headers were already sent.
Traceback (most recent call last):
  File "/home/user/proj/.venv/lib/python3.12/site-packages/flask/app.py", line 1498, in __call__
    return self.wsgi_app(environ, start_response)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/proj/.venv/lib/python3.12/site-packages/whitenoise/base.py", line 81, in __call__
    return self.application(environ, start_response)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/proj/.venv/lib/python3.12/site-packages/werkzeug/middleware/proxy_fix.py", line 183, in __call__
    return self.app(environ, start_response)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/proj/.venv/lib/python3.12/site-packages/opentelemetry/instrumentation/flask/__init__.py", line 390, in _wrapped_app
    result = wsgi_app(wrapped_app_environ, _start_response)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/proj/.venv/lib/python3.12/site-packages/flask/app.py", line 1489, in wsgi_app
    ctx.pop(error)
  File "/home/user/proj/.venv/lib/python3.12/site-packages/flask/ctx.py", line 426, in pop
    app_ctx.pop(exc)
  File "/home/user/proj/.venv/lib/python3.12/site-packages/flask/ctx.py", line 262, in pop
    self.app.do_teardown_appcontext(exc)
  File "/home/user/proj/.venv/lib/python3.12/site-packages/flask/app.py", line 1344, in do_teardown_appcontext
    self.ensure_sync(func)(exc)
RuntimeError: You cannot use AsyncToSync in the same thread as an async event loop - just await the async function directly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant