20 lines
612 B
Python
20 lines
612 B
Python
from background_task import background
|
|
from channels.layers import get_channel_layer
|
|
from asgiref.sync import async_to_sync
|
|
from polls.models import Message
|
|
|
|
|
|
@background(schedule=1)
|
|
def process_task(task, groups, user_id):
|
|
print(groups)
|
|
for g in groups:
|
|
print(g)
|
|
# async_to_sync(channel_layer.group_send)(g['id'], {
|
|
# "type": 0,
|
|
# "send_from": user_id,
|
|
# "group_id": g['id'],
|
|
# "content": task['content']
|
|
# })
|
|
channel_layer = get_channel_layer()
|
|
async_to_sync(channel_layer.send)('test_channel', {'type': g['id']})
|