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
# Broadcast trade to all connected clients via channel layer (websockets)
try:
from channels.layers import get_channel_layer
channel_layer = get_channel_layer()
await channel_layer.group_send(
str(bot.id), # The bot's id is used as the group name
{
'type': 'bot_trade', # This matches the name of a method in the consumer
'message': {MESSAGEREMOVED},
}
)
except Exception as e:
# Failed to broadcast trade
print(e)
this is being called from a django view which executes a trade function, that trade function executes another function where this call is located.
an error always pops up in the terminal "The caller tried using channels_rabbitmq on a different event loop than the one it was initialized with."
Usually this error happens when trying to use django channels logic inside a celery function but I'm not.
Do you know what could be going wrong?
The text was updated successfully, but these errors were encountered:
I see an await so I assume that means you're using Django async views....
In which case: big shrug from me. Your app is somehow using multiple event loops.
Try to produce a reduction: greatly simplify your app to make the error go away. Remove auth, and test again. Remove all other views, then test. Remove each middleware, testing after each. When the error goes away, it's probably from the most-recently-deleted code. Stare there and try to figure out what's up.
Worst case, you end up with just two or three files in your Django app -- and at this point, you'll have no business logic or personally identifiable information. If this mini-app still reports this message, please publish it as a GitHub project and link to it here.
So I was on a long break for a while from this project, and recently started working on it again. I'm in the process of testing this but it seems that the server I'm using to deploy eventually and test in development at the moment "daphne". Uses multiple cores to do concurrency. I locked the daphne server to only run on one core and from the print statements I added it seems like the problem could be caused by that. Switching threads essentially on different cores and that not working well with channels_rabbitMQ. I'll update upon further testing to let you know.
I don't really understand what is causing the issue.
I have my configuration setup like so:
And I'm trying to call this:
this is being called from a django view which executes a trade function, that trade function executes another function where this call is located.
an error always pops up in the terminal "The caller tried using channels_rabbitmq on a different event loop than the one it was initialized with."
Usually this error happens when trying to use django channels logic inside a celery function but I'm not.
Do you know what could be going wrong?
The text was updated successfully, but these errors were encountered: