Пример #1
0
def has_cron(func):
    if type(func) == str:
        func_name = func
    else:
        func_name = func.__raw__.__name__
    for cron in model.get_cron_set():
        if cron['func_name'] == func_name:
            return True
    return False
Пример #2
0
def remove_cron(func):
    cron_set = model.get_cron_set()
    if type(func) == str:
        func_name = func
    else:
        func_name = func.__raw__.__name__
    for cron in cron_set:
        if cron['func_name'] == func_name:
            cron_set.remove(cron)
Пример #3
0
Файл: cron.py Проект: ytf513/ztq
def remove_cron(func):
    cron_set = model.get_cron_set()
    if type(func) == str:
        func_name = func
    else:
        func_name = func.__raw__.__name__
    for cron in cron_set:
        if cron['func_name'] == func_name:
            cron_set.remove(cron)
Пример #4
0
Файл: cron.py Проект: ytf513/ztq
def has_cron(func):
    if type(func) == str:
        func_name = func
    else:
        func_name = func.__raw__.__name__
    for cron in model.get_cron_set():
        if cron['func_name'] == func_name:
            return True
    return False
Пример #5
0
    def run(self):
        """
            获取cron_info信息格式:{'minute':3, 'hour':3,}
        """
        cron_set = model.get_cron_set()
        while True:
            # 遍历cron列表检查并检查定时执行信息
            for cron in cron_set:
                execute_flag = self.check_cron_info(cron['cron_info'])
                if execute_flag:
                    push_task(cron['queue'] + ':' + cron['func_name'], *cron['args'], **cron['kw'])

            time.sleep(55)
Пример #6
0
Файл: cron.py Проект: ytf513/ztq
    def run(self):
        """
            获取cron_info信息格式:{'minute':3, 'hour':3,}
        """
        cron_set = model.get_cron_set()
        while True:
            # 遍历cron列表检查并检查定时执行信息
            for cron in cron_set:
                execute_flag = self.check_cron_info(cron['cron_info'])
                if execute_flag:
                    push_task(cron['queue'] + ':' + cron['func_name'],
                              *cron['args'], **cron['kw'])

            time.sleep(55)
Пример #7
0
def add_cron(cron_info, full_func, *args, **kw):
    """ 定时执行 

    cron_info: {'minute':3, 'hour':3,}
    """
    cron_set = model.get_cron_set()
    if type(full_func) == str:
        queue_name, func_name = split_full_func_name(full_func)
    else:
        queue_name = full_func._ztq_queue
        func_name = full_func.__raw__.__name__
    cron_set.add({'func_name':func_name, 
                'cron_info':cron_info,
                'queue': queue_name,
                'args':args,
                'kw':kw})
Пример #8
0
Файл: cron.py Проект: ytf513/ztq
def add_cron(cron_info, full_func, *args, **kw):
    """ 定时执行 

    cron_info: {'minute':3, 'hour':3,}
    """
    cron_set = model.get_cron_set()
    if type(full_func) == str:
        queue_name, func_name = split_full_func_name(full_func)
    else:
        queue_name = full_func._ztq_queue
        func_name = full_func.__raw__.__name__
    cron_set.add({
        'func_name': func_name,
        'cron_info': cron_info,
        'queue': queue_name,
        'args': args,
        'kw': kw
    })