Example #1
0
def revoke(request):
    from celery.task.control import revoke
    from voxel_globe.websockets import ws_logger
    import voxel_globe.meta.models

    task_id = request.POST["task_id"]
    revoke(task_id, terminate=True)

    service_instance = voxel_globe.meta.models.ServiceInstance.objects.get(id=int(task_id))
    service_instance.status = "Revoked"
    service_instance.save()

    ws_logger.send_status_update(task_id, service_instance.service_name, "Revoked", None)
    return HttpResponse("")
Example #2
0
  def on_success(self, retval, task_id, args, kwargs):
    #I can't currently tell if apply or apply_async is called, but I don't 
    #think I care either. I could check status since I differentiate them there 

    from voxel_globe.websockets import ws_logger

    service_instance = get_service_instance(task_id)

    service_instance.outputs = json.dumps(retval)
    service_instance.status = 'Success'
    service_instance.save()

    ws_logger.send_status_update(task_id=self.request.id, task_name=self.name, 
                                 status="Success", result=retval)
Example #3
0
  def update_state(self, task_id=None, state=None, meta=None):
    from voxel_globe.websockets import ws_logger

    logger.debug('update_state: Task: %s State: %s Meta: %s', task_id, state, 
                 meta)

    service_instance = get_service_instance(self.request.id)
    service_instance.outputs = json.dumps(meta)
    service_instance.status = state
    service_instance.save()

    ws_logger.send_status_update(task_id=self.request.id, task_name=self.name, 
                                 status=state, result=meta)

    return super(VipTask, self).update_state(task_id, state, meta)
Example #4
0
def revoke(request):
  from celery.task.control import revoke
  from voxel_globe.websockets import ws_logger
  import voxel_globe.meta.models

  task_id = request.POST['task_id']
  revoke(task_id, terminate=True)
  
  service_instance = voxel_globe.meta.models.ServiceInstance.objects.get(
        id=int(task_id))
  service_instance.status = 'Revoked'
  service_instance.save()
  
  ws_logger.send_status_update(task_id, service_instance.service_name, \
    "Revoked", None)
  return HttpResponse('')
Example #5
0
  def on_failure(self, exc, task_id, args, kwargs, einfo):
    from voxel_globe.websockets import ws_logger

    if env['VIP_CELERY_DBSTOP_IF_ERROR']=='1':
      import traceback
      import sys
      import vsi.tools.vdb_rpdb as vdb
      import socket

      traceback.print_exception(*sys.exc_info())

      print 'Hostname:', socket.gethostname()
      vdb.post_mortem(ip='0.0.0.0')
    
    service_instance = get_service_instance(task_id)
    service_instance.outputs = json.dumps({"traceback" : str(einfo)})
    service_instance.status = 'Failure'
    service_instance.save()

    ws_logger.send_status_update(task_id=self.request.id, task_name=self.name, 
                                 status="Failure", result={"traceback" : str(einfo)})