本文整理汇总了Python中celery.beat.Scheduler.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python Scheduler.__init__方法的具体用法?Python Scheduler.__init__怎么用?Python Scheduler.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类celery.beat.Scheduler
的用法示例。
在下文中一共展示了Scheduler.__init__方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from celery.beat import Scheduler [as 别名]
# 或者: from celery.beat.Scheduler import __init__ [as 别名]
def __init__(self, *args, **kwargs):
self._schedule = {}
self._last_updated = None
Scheduler.__init__(self, *args, **kwargs)
self.max_interval = (kwargs.get('max_interval')
or self.app.conf.CELERYBEAT_MAX_LOOP_INTERVAL or 300)
self.db = db_factory.get_database()
示例2: __init__
# 需要导入模块: from celery.beat import Scheduler [as 别名]
# 或者: from celery.beat.Scheduler import __init__ [as 别名]
def __init__(self, *args, **kwargs):
self._dirty = set()
self._last_flush = None
self._flush_every = 3 * 60
self._finalize = Finalize(self, self.flush, exitpriority=5)
Scheduler.__init__(self, *args, **kwargs)
self.max_interval = 5
示例3: __init__
# 需要导入模块: from celery.beat import Scheduler [as 别名]
# 或者: from celery.beat.Scheduler import __init__ [as 别名]
def __init__(self, *args, **kwargs):
self._dirty = set()
self._finalize = Finalize(self, self.sync, exitpriority=5)
Scheduler.__init__(self, *args, **kwargs)
self.max_interval = (kwargs.get("max_interval")
or self.app.conf.CELERYBEAT_MAX_LOOP_INTERVAL
or DEFAULT_MAX_INTERVAL)
示例4: __init__
# 需要导入模块: from celery.beat import Scheduler [as 别名]
# 或者: from celery.beat.Scheduler import __init__ [as 别名]
def __init__(self, *args, **kwargs):
if hasattr(current_app.conf, "CELERY_MONGODB_SCHEDULER_DB"):
db = current_app.conf.CELERY_MONGODB_SCHEDULER_DB
else:
db = "celery"
if hasattr(current_app.conf, "CELERY_MONGODB_SCHEDULER_COLLECTION") \
and current_app.conf.CELERY_MONGODB_SCHEDULER_COLLECTION:
collection=current_app.conf.CELERY_MONGODB_SCHEDULER_COLLECTION
else:
collection="schedules"
if hasattr(current_app.conf, "CELERY_MONGODB_SCHEDULER_URL"):
connection=Connection(current_app.conf.CELERY_MONGODB_SCHEDULER_URL)
get_logger(__name__).info("backend scheduler using %s/%s:%s",
current_app.conf.CELERY_MONGODB_SCHEDULER_DB,
db,collection)
else:
connection=Connection()
self.db=connection[db][collection]
self._schedule = {}
self._last_updated = None
Scheduler.__init__(self, *args, **kwargs)
self.max_interval = (kwargs.get('max_interval') \
or self.app.conf.CELERYBEAT_MAX_LOOP_INTERVAL or 300)
示例5: __init__
# 需要导入模块: from celery.beat import Scheduler [as 别名]
# 或者: from celery.beat.Scheduler import __init__ [as 别名]
def __init__(self, *args, **kwargs):
if hasattr(current_app.conf, 'CELERY_REDIS_SCHEDULER_URL'):
logger.info('backend scheduler using %s',
current_app.conf.CELERY_REDIS_SCHEDULER_URL)
else:
logger.info('backend scheduler using %s',
current_app.conf.CELERY_REDIS_SCHEDULER_URL)
# how long we should hold on to the redis lock in seconds
if 'CELERY_REDIS_SCHEDULER_LOCK_TTL' in current_app.conf:
lock_ttl = current_app.conf.CELERY_REDIS_SCHEDULER_LOCK_TTL
else:
lock_ttl = 30
if lock_ttl < self.UPDATE_INTERVAL.seconds:
lock_ttl = self.UPDATE_INTERVAL.seconds * 2
self.lock_ttl = lock_ttl
self._schedule = {}
self._last_updated = None
self._lock_acquired = False
Scheduler.__init__(self, *args, **kwargs)
self.max_interval = (kwargs.get('max_interval') \
or self.app.conf.CELERYBEAT_MAX_LOOP_INTERVAL or 300)
self._lock = rdb.lock('celery:beat:task_lock', timeout=self.lock_ttl)
self._lock_acquired = self._lock.acquire(blocking=False)
self.Entry.scheduler = self
示例6: __init__
# 需要导入模块: from celery.beat import Scheduler [as 别名]
# 或者: from celery.beat.Scheduler import __init__ [as 别名]
def __init__(self, *args, **kwargs):
"""Initialize the database scheduler."""
self._dirty = set()
Scheduler.__init__(self, *args, **kwargs)
self._finalize = Finalize(self, self.sync, exitpriority=5)
self.max_interval = (
kwargs.get('max_interval')
or self.app.conf.beat_max_loop_interval
or DEFAULT_MAX_INTERVAL)
示例7: __init__
# 需要导入模块: from celery.beat import Scheduler [as 别名]
# 或者: from celery.beat.Scheduler import __init__ [as 别名]
def __init__(self, *args, **kwargs):
log.info("SQLAlchemyScheduler.__init__ called")
self._dirty = set()
Scheduler.__init__(self, *args, **kwargs)
self.max_interval = (
kwargs.get('max_interval') or
self.app.conf.CELERYBEAT_MAX_LOOP_INTERVAL or
DEFAULT_MAX_INTERVAL)
示例8: __init__
# 需要导入模块: from celery.beat import Scheduler [as 别名]
# 或者: from celery.beat.Scheduler import __init__ [as 别名]
def __init__(self, *args, **kwargs):
if hasattr(current_app.conf, 'CELERY_REDIS_SCHEDULER_URL'):
get_logger(__name__).info('backend scheduler using %s',
current_app.conf.CELERY_REDIS_SCHEDULER_URL)
else:
get_logger(__name__).info('backend scheduler using %s',
current_app.conf.CELERY_REDIS_SCHEDULER_URL)
self._schedule = {}
self._last_updated = None
Scheduler.__init__(self, *args, **kwargs)
self.max_interval = (kwargs.get('max_interval') \
or self.app.conf.CELERYBEAT_MAX_LOOP_INTERVAL or 300)
示例9: __init__
# 需要导入模块: from celery.beat import Scheduler [as 别名]
# 或者: from celery.beat.Scheduler import __init__ [as 别名]
def __init__(self, *args, **kwargs):
self.data = {}
self.last_refresh = None
if 'LEEK_REDIS_URL' not in current_app.conf:
raise Exception('Missing LEEK_REDIS_URL celery config')
self.hash_key = current_app.conf.get('LEEK_HASH_KEY', 'leek')
self.redis = redis.from_url(current_app.conf.get('LEEK_REDIS_URL'))
self.tz = timezone.get_timezone(current_app.conf.get('CELERY_TIMEZONE', 'UTC'))
Scheduler.__init__(self, *args, **kwargs)
self.max_interval = self.app.conf.get('LEEK_REFRESH_INTERVAL', 5)
self.refresh_frequency = timedelta(seconds=self.max_interval)
示例10: __init__
# 需要导入模块: from celery.beat import Scheduler [as 别名]
# 或者: from celery.beat.Scheduler import __init__ [as 别名]
def __init__(self, *args, **kwargs):
if hasattr(current_app.conf, 'CELERY_REDIS_SCHEDULER_URL'):
logger.info('backend scheduler using %s',
current_app.conf.CELERY_REDIS_SCHEDULER_URL)
else:
logger.info('backend scheduler using %s',
current_app.conf.CELERY_REDIS_SCHEDULER_URL)
self._schedule = {}
self._last_updated = None
Scheduler.__init__(self, *args, **kwargs)
self.max_interval = (kwargs.get('max_interval') \
or self.app.conf.CELERYBEAT_MAX_LOOP_INTERVAL or 300)
self._lock = rdb.lock('celery:beat:task_lock')
self._lock_acquired = self._lock.acquire(blocking=False)
self.Entry.scheduler = self
示例11: __init__
# 需要导入模块: from celery.beat import Scheduler [as 别名]
# 或者: from celery.beat.Scheduler import __init__ [as 别名]
def __init__(self, *args, **kwargs):
if hasattr(current_app.conf, "CELERY_MONGODB_SCHEDULER_DB"):
db = current_app.conf.CELERY_MONGODB_SCHEDULER_DB
else:
db = "celery"
if hasattr(current_app.conf, "CELERY_MONGODB_SCHEDULER_URL"):
self._mongo = mongoengine.connect(db, host=current_app.conf.CELERY_MONGODB_SCHEDULER_URL)
get_logger(__name__).info("backend scheduler using %s/%s:%s",
current_app.conf.CELERY_MONGODB_SCHEDULER_URL,
db, self.Model._get_collection().name)
else:
self._mongo = mongoengine.connect(db)
get_logger(__name__).info("backend scheduler using %s/%s:%s",
"mongodb://localhost",
db, self.Model._get_collection().name)
self._schedule = {}
self._last_updated = None
Scheduler.__init__(self, *args, **kwargs)
self.max_interval = (kwargs.get('max_interval')
or self.app.conf.CELERYBEAT_MAX_LOOP_INTERVAL or 5)
示例12: __init__
# 需要导入模块: from celery.beat import Scheduler [as 别名]
# 或者: from celery.beat.Scheduler import __init__ [as 别名]
def __init__(self, app, **kwargs):
self._last_timestamp = self._get_latest_change()
Scheduler.__init__(self, app, **kwargs)
示例13: __init__
# 需要导入模块: from celery.beat import Scheduler [as 别名]
# 或者: from celery.beat.Scheduler import __init__ [as 别名]
def __init__(self, *args, **kwargs):
self._dirty = set()
self._finalize = Finalize(self, self.sync, exitpriority=5)
Scheduler.__init__(self, *args, **kwargs)
self.max_interval = 5
示例14: __init__
# 需要导入模块: from celery.beat import Scheduler [as 别名]
# 或者: from celery.beat.Scheduler import __init__ [as 别名]
def __init__(self, *args, **kwargs):
Scheduler.__init__(self, *args, **kwargs)
self.max_interval = 5
self._dirty = set()
self._last_flush = None
self._flush_every = 3 * 60
示例15: cls
# 需要导入模块: from celery.beat import Scheduler [as 别名]
# 或者: from celery.beat.Scheduler import __init__ [as 别名]
return cls(db_entry)
class DatabaseScheduler(Scheduler):
Entry = Entry
_last_timestamp = None
_schedule = None
_initial_read = False
def __init__(self, app, **kwargs):
<<<<<<< HEAD
print 'DBScheduler initiated'
=======
>>>>>>> eb2a33c4b2f857754113985e104210382f7b5a44
self._last_timestamp = self._get_latest_change()
Scheduler.__init__(self, app, **kwargs)
def _get_latest_change(self):
query = dbsession.query(DatabaseSchedulerEntry.date_changed)
query = query.order_by(DatabaseSchedulerEntry.date_changed.desc())
latest_entry_date = query.first()
return latest_entry_date
def setup_schedule(self):
self.install_default_entries(self.schedule)
self.update_from_dict(self.app.conf.CELERYBEAT_SCHEDULE)
def _all_as_schedule(self):
s = {}
query = dbsession.query(DatabaseSchedulerEntry)
query = query.filter_by(enabled=True)