Ejemplo n.º 1
0
 def process(self,info):
     """main process"""
     try:
         result =True
         code = 0
         msg="OK"
         detail ={}
         #
         r_params_steps = info.get("body",{}).get("params",{}).get("steps",[])
         if r_params_steps:
             info["already_run_step"]=[]
             info["ready_run_step"]=r_params_steps
             tmp_step = info["ready_run_step"].pop(0)
             info["module"]=tmp_step.get("module","demo")
             info["current_step"]=tmp_step.get("method","")
             #
             log("&&&&&&&&&&&&&&&&&&&&&&&&&Info&&&&&&&&&&&&")
             log(str(info))
             t_send_info=callback_format(info,detail,result,code,msg)
             send_callback(json.dumps(t_send_info),t_send_info["module"])
         else:
             log("*"*30)
             log("[PreTaskProcess][Input Info Miss step]%s"%(json.dumps(info)))
             log("*"*30)
     except Exception,e:
         result = False
         code =1
         msg=str(e)
         detail ={}
         log(traceback.print_exc())
Ejemplo n.º 2
0
        #print e
        #print traceback.print_exc()
        result=False
        code = 1
        msg=traceback.print_exc()
        info ={}
        detail ={}
        log(msg)
    finally:
        #callback execute result msg
        if method.routing_key in ("callback","preprocess"):
            pass

        else:
            t_info =callback_format(info,detail,result,code,msg)
            try:
                send_callback(json.dumps(t_info))
            except Exception,e:
                print  traceback.print_exc()
                log(traceback.print_exc())
    #print dir(method)
    #print
    #print dir(ch)
    ch.basic_ack(delivery_tag=method.delivery_tag)

channel.basic_qos(prefetch_count=1)
channel.basic_consume(callback,
                      queue=queue_name,
                      no_ack=False)

channel.start_consuming()