from asgiref.sync import async_to_sync from channels.layers import get_channel_layer def notify_sessions(event, data): def wrapper(func): def wrapped(*args, **kwargs): ret = func(*args, **kwargs) channel_layer = get_channel_layer() async_to_sync(channel_layer.group_send)( event, { 'type': 'notify', 'data': data, } ) return ret return wrapped return wrapper