You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to find a way to send events to each client based on a Redis pub sub channel. Not sharing all events like AsyncRedisManager but with specific events and behavior. In my attempts I have encountered strange behavior that only exists with the combination of aioredis and python-socketio.
This is the method I'm looking to run for each client:
This causes strange Task was destroyed but it is pending! errors when overlapping requests come in (even with async_handlers=False). My guess was that this was something with ASGI cancelling the event loop, but this proves to be false by the bottom most method.
As mentioned here, this seems to create a new thread and emitting events from multiple threads isn't supported. I also encountered some strange behavior with this, possibly for this reason.
aioredis mentions it only supports single subscriber consumers, but the above code fails with the Task was destroyed but it is pending! error even when just a single subscriber is instantiated. Additionally, I've tried using it with snippets that provide multi-consumer support but the behavior was the same.
As mentioned briefly at the start, running this same code without any references to sio works without errors.
Sorry for such a long issue description xD.
The text was updated successfully, but these errors were encountered:
You omitted the most important thing: the error that you are getting. Can you please include the complete text of the error (including stacktrace). Also, if you have an alternative code that works, can you show me that as well?
I'm trying to find a way to send events to each client based on a Redis pub sub channel. Not sharing all events like
AsyncRedisManager
but with specific events and behavior. In my attempts I have encountered strange behavior that only exists with the combination ofaioredis
andpython-socketio
.This is the method I'm looking to run for each client:
I've attempted a number of methods, each which error in some way:
Within handler:
This seems to prevent new connections entirely.
Within task created by handler:
This causes strange
Task was destroyed but it is pending!
errors when overlapping requests come in (even withasync_handlers=False
). My guess was that this was something withASGI
cancelling the event loop, but this proves to be false by the bottom most method.Using
start_background_task
:As mentioned here, this seems to create a new thread and emitting events from multiple threads isn't supported. I also encountered some strange behavior with this, possibly for this reason.
Using queue with single async consumer:
However, surprisingly, this still causes
Task was destroyed but it is pending!
momentarily aftersio.emit(...)
withinhandle_progress
.If I swap out
subscribe_redis
withfake_subscribe_redis
that simply yields everyN
milliseconds, everything seems to behave normally.So, I have two questions:
python-socketio
's perspective?For reference, here are
subscribe_redis
andfake_subscribe_redis
:Notes:
aioredis
mentions it only supports single subscriber consumers, but the above code fails with theTask was destroyed but it is pending!
error even when just a single subscriber is instantiated. Additionally, I've tried using it with snippets that provide multi-consumer support but the behavior was the same.sio
works without errors.Sorry for such a long issue description xD.
The text was updated successfully, but these errors were encountered: