Send a channel layer group message without blocking the gevent hub.
(channel_layer, group, message)
| 887 | |
| 888 | |
| 889 | def _send_async(channel_layer, group, message): |
| 890 | """Send a channel layer group message without blocking the gevent hub.""" |
| 891 | def _do(): |
| 892 | try: |
| 893 | async_to_sync(channel_layer.group_send)(group, message) |
| 894 | except Exception as e: |
| 895 | logger.warning(f"Failed WebSocket group_send to '{group}': {e}") |
| 896 | |
| 897 | try: |
| 898 | import gevent.monkey |
| 899 | if gevent.monkey.is_module_patched("threading"): |
| 900 | import gevent |
| 901 | gevent.spawn(_gevent_ws_send, group, message) |
| 902 | return |
| 903 | except Exception: |
| 904 | pass |
| 905 | _do() |
| 906 | |
| 907 | |
| 908 | def send_websocket_notification(notification): |
no test coverage detected