def __init__(self, **kwargs): self._module_dict = {} self._redis_client = RedisClient(host=config_setting.queue_host, port=config_setting.queue_port, password=config_setting.queue_pwd) self._queue_list = [LOGIN_QUEUE,CTASK_QUEUE,UPDATE_QUEUE] self._task_queue = Queue() # self.init_modules() gevent.spawn(self._get_task) gevent.spawn(self._dispatch_task) gevent.sleep()
def __init__(self, **kwargs): if ('host' in kwargs) and ('port' in kwargs) and ('pwd' in kwargs): self._host = kwargs['host'] self._port = kwargs['port'] self._port = kwargs['pwd'] else: self._host = config_setting.queue_host self._port = config_setting.queue_port self._pwd = config_setting.queue_pwd self._queue = 'ultron:cache' self._zip_level = 9 #创建redis连接 self._redis_client = RedisClient(host=self._host, port=self._port, password=self._pwd, db=6)
def __init__(self, **kwargs): self._module_dict = {} self._redis_client = RedisClient(host=config_setting.queue_host, port=config_setting.queue_port, password=config_setting.queue_pwd) self._secret_key = 'd6f89b09' self._wid = unique_machine self._queue_list = ['ultron:work:work_id:' + str(self._wid)] #生成token self._token = hashlib.sha1( (self._secret_key + self._wid.replace('-', '')).encode()).hexdigest() self._task_queue = Queue() # self.init_modules() gevent.spawn(self._get_task) gevent.spawn(self._dispatch_task) gevent.spawn(self._heart_tick) gevent.sleep()
# -*- coding: utf-8 -*- import sys import json import datetime import time sys.path.append('..') from ultron.utilities.redis.redis_client import RedisClient redis_client = RedisClient(host='47.95.193.202',port=6378,password='******') task_id = time.time() * 1000000 + datetime.datetime.now().microsecond task_info = {'name':'tasks','opcode':'shutoff_task','work_name':'polymeriza','dir_name':'./q7_task'} redis_client.hset('ultron:work:ctask',str(task_id),json.dumps(task_info))