django / channels

Developer-friendly asynchrony for Django
https://channels.readthedocs.io
BSD 3-Clause "New" or "Revised" License
6.11k stars 800 forks source link

Use group_send() when group is empty #2096

Closed MYWpro closed 6 months ago

MYWpro commented 6 months ago

Hello, in the case of Outside Of Consumers, if the Group is empty, that is, there is no channel in it, what will be the consequences of calling channel_layer.group_send("group_name", )? Will an error be reported? My backend runs multiple long-term threads to perform AI predictions on the video stream. I want to return the processed video frames to the web frontend for display only when the user needs to view them. So I want to implement this function by using the group_send() function in my video stream processing thread. But I don’t know if there will be an error when executing the group_send() function when there is no client connection?
I would be grateful if you could answer the question.

carltongibson commented 6 months ago

There's no built in API for tracking group memberships, and no error sending to an empty group. You'd need to build something to monitor that. You could maybe set a state flag somewhere when joining for example.