Skip to content

Instantly share code, notes, and snippets.

@marcelcaraciolo
Created February 18, 2014 02:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcelcaraciolo/9063656 to your computer and use it in GitHub Desktop.
Save marcelcaraciolo/9063656 to your computer and use it in GitHub Desktop.
Agendamento
from __future__ import absolute_import
from celery import shared_task
# import the logging library
import logging
# Get an instance of a logger
logger = logging.getLogger(__name__)
@shared_task
def sendScheduledAlertTask(pk, scheduling_id):
from alerts.models import MaintenanceAlert
logger.info('entrei no task com pk igual a e tipo ' + str(pk) + str(type(pk)))
logger.info('tentei chegar no scheduling_id com ' + str(scheduling_id))
try:
alert = MaintenanceAlert.objects.get(pk=pk)
except MaintenanceAlert.DoesNotExist:
return
logger.info('entrei no task com o alerta %s' % alert.name)
if alert.status == MaintenanceAlert.SCHEDULED_TO_SEND and alert.scheduling_id == scheduling_id:
logger.info('entrei na atividade com o alerta %s' % alert.name)
alert.task_id = None
alert.scheduling_id = None
alert.save()
alert.send()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment