Flask-socketio: Using Redis without monkey patching

Created on 23 Oct 2020  Â·  5Comments  Â·  Source: miguelgrinberg/Flask-SocketIO

Hey,

I'd like to add Redis message queue and I started by monkey patching the eventlet.
However, the app crashes as a result of an SSL error. there are some related issues on eventlet but I couldn't find a solution.
Is it possible to use aioredis instead of pyredis and by that avoid monkey patching.

Thanks!

For future reference, the errors I'm getting:

Traceback (most recent call last):
  File "/Users/user/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_trace_dispatch_regular.py", line 356, in __call__
    is_stepping = pydev_step_cmd != -1
RecursionError: maximum recursion depth exceeded in comparison
Fatal Python error: Cannot recover from stack overflow.
Python runtime state: initialized

And then:

Traceback (most recent call last):
  File "/Users/user/Documents/Code/knowpro/knowpro-backend/venv/lib/python3.8/site-packages/eventlet/hubs/hub.py", line 472, in fire_timers
    timer()
  File "/Users/user/Documents/Code/knowpro/knowpro-backend/venv/lib/python3.8/site-packages/eventlet/hubs/timer.py", line 59, in __call__
    cb(*args, **kw)
  File "/Users/user/Documents/Code/knowpro/knowpro-backend/venv/lib/python3.8/site-packages/eventlet/semaphore.py", line 147, in _do_acquire
    waiter.switch()
greenlet.error: cannot switch to a different thread
question

All 5 comments

Aioredis only works with asyncio, so no, you cannot use it with Flask. The SSL bugs in eventlet only exist in certain versions of Python, so you may want to test other versions to see if things work better, or else try gevent instead of eventlet.

I’ll give it a try. Thanks!

Do you have a recommendation for a Python version that works for you?

On Fri, Oct 23, 2020 at 02:31 Miguel Grinberg notifications@github.com
wrote:

Aioredis only works with asyncio, so no, you cannot use it with Flask. The
SSL bugs in eventlet only exist in certain versions of Python, so you may
want to test other versions to see if things work better.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/miguelgrinberg/Flask-SocketIO/issues/1396#issuecomment-715223258,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AEC2OROSOW324QKPFLGPAGLSMFENJANCNFSM4S34VJFA
.

@ranihorev Sorry, but I don't really know. This has never been a problem I've seen myself, but it is frequently reported by users of this package.

I'll try switching and post my findings here (and close this issue). Thanks again!

I ended up using gunicorn instead. It handles the monkey-patching for me instead.
Closing this issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

blstdmi picture blstdmi  Â·  3Comments

fbussv picture fbussv  Â·  4Comments

novice79 picture novice79  Â·  3Comments

nayebare picture nayebare  Â·  4Comments

chaitanyavolkaji picture chaitanyavolkaji  Â·  3Comments