# Path: celeryapp/celery.py
# def save_state(sender=None, conf=None, **kwargs):
# def get_message_queue_size(queue_name):
# IP = re.compile(r'\d{1,3}(?:\.\d{1,3}){3}(?::\d{1,6})?')
# 
# Path: celeryapp/celery.py
# def get_message_queue_size(queue_name):
#     client = redis.Redis(IP.findall(config.broker)[0])
#     length = client.llen(queue_name)
#     return length


from celeryapp.celery import app
from celeryapp.celery import get_message_queue_size
from celery import group
from celery.exceptions import Retry
import datetime
import config
import celeryconfig
            self.scheduler.save_filter()
            return

        #  initcail tasks:
        if not tasks and not check_task:
            for task in self.scheduler.init_generator():
                if task.get('priority', None):
                    #app.tasks[self.crawler_name+'.request_priority'].delay(task)
                    app.tasks[self.crawler_name+'.request_priority'].apply_async((task, ), compression='zlib')
                else:
                    #app.tasks[self.crawler_name+'.request'].delay(task)
                    app.tasks[self.crawler_name+'.request'].apply_async((task, ), compression='zlib')
                #group(app.tasks[self.crawler_name + '.request'].s(task) 
                #        | app.tasks[self.crawler_name + '.parse'].s() 
                #        | app.tasks[self.crawler_name + '.pipeline'].s()
                #        ).delay()
            #app.tasks[self.crawler_name+'.schedule'].apply_async(
            #        args=[],
            #        kwargs = {
            #            'check_task': True,
            #            },
            #        eta=datetime.datetime.now())
        # add new tasks, call by task.apply
        elif tasks and not check_task:
            self.scheduler.add_new_task(tasks)
                #app.tasks[self.crawler_name+'.new_task'].delay(task)
        # schedule task
        elif check_task:
            #i = app.control.inspect()
            timedelta = config.new_task_check_interval

# Path: celeryapp/celery.py
# def save_state(sender=None, conf=None, **kwargs):
# def get_message_queue_size(queue_name):
# IP = re.compile(r'\d{1,3}(?:\.\d{1,3}){3}(?::\d{1,6})?')
# 
# Path: celeryapp/celery.py
# def get_message_queue_size(queue_name):
#     client = redis.Redis(IP.findall(config.broker)[0])
#     length = client.llen(queue_name)
#     return length


# Path: celeryapp/crawl_tasks.py
from celeryapp.celery import app
from celeryapp.celery import get_message_queue_size
from celery import group
from celery.exceptions import Retry
import datetime
import config
import celeryconfig

            self.scheduler.save_filter()
            return

        #  initcail tasks:
        if not tasks and not check_task:
            for task in self.scheduler.init_generator():
                if task.get('priority', None):
                    #app.tasks[self.crawler_name+'.request_priority'].delay(task)
                    app.tasks[self.crawler_name+'.request_priority'].apply_async((task, ), compression='zlib')
                else:
                    #app.tasks[self.crawler_name+'.request'].delay(task)
                    app.tasks[self.crawler_name+'.request'].apply_async((task, ), compression='zlib')
                #group(app.tasks[self.crawler_name + '.request'].s(task) 
                #        | app.tasks[self.crawler_name + '.parse'].s() 
                #        | app.tasks[self.crawler_name + '.pipeline'].s()
                #        ).delay()
            #app.tasks[self.crawler_name+'.schedule'].apply_async(
            #        args=[],
            #        kwargs = {
            #            'check_task': True,
            #            },
            #        eta=datetime.datetime.now())
        # add new tasks, call by task.apply
        elif tasks and not check_task:
            self.scheduler.add_new_task(tasks)
                #app.tasks[self.crawler_name+'.new_task'].delay(task)
        # schedule task
        elif check_task:
            #i = app.control.inspect()
            timedelta = config.new_task_check_interval

            if (get_message_queue_size('request') < config.max_task_queue_size):