Browse Source

Att celery

Websocket_painel
Gustavo274 3 years ago
parent
commit
132899fe89
  1. BIN
      celerybeat-schedule
  2. BIN
      dump.rdb
  3. 17
      sapl/celery.py
  4. 19
      sapl/painel/tasks.py

BIN
celerybeat-schedule

Binary file not shown.

BIN
dump.rdb

Binary file not shown.

17
sapl/celery.py

@ -0,0 +1,17 @@
import os
from celery import Celery
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'sapl.settings')
app = Celery('sapl')
app.config_from_object('django.conf:settings', namespace='CELERY')
app.conf.beat_schedule = {
'get_cronometro_inst': {
'task': 'sapl.painel.tasks.get_cronometro',
'schedule': 10.0
}
}
app.autodiscover_tasks()

19
sapl/painel/tasks.py

@ -0,0 +1,19 @@
import json
import requests
import urllib
from celery import shared_task
@shared_task
def get_cronometro():
url_dados = 'http://localhost:8000/painel/1272/dados'
# print(requests.get(url_dados).status_code)
#response = requests.get(url_dados)
response = urllib.request.urlopen(url_dados)
dados = json.loads(response.read())
#cronometro = response['sessao_plenaria']['cronometro_discurso']
print(dados)
print(response)
print(response.encoding)
return response
Loading…
Cancel
Save