本文整理汇总了Python中celery.beat.ScheduleEntry方法的典型用法代码示例。如果您正苦于以下问题:Python beat.ScheduleEntry方法的具体用法?Python beat.ScheduleEntry怎么用?Python beat.ScheduleEntry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类celery.beat
的用法示例。
在下文中一共展示了beat.ScheduleEntry方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_serialize_entry_json_serializable
# 需要导入模块: from celery import beat [as 别名]
# 或者: from celery.beat import ScheduleEntry [as 别名]
def test_serialize_entry_json_serializable(dt):
entry = ScheduleEntry(
name='entry-1',
task='entry-1-task',
schedule=dt,
args=('arg1', 'arg2'),
kwargs={'key1': 'val1', 'key2': 'val2'},
last_run_at=datetime.now(),
total_run_count=1,
options={},
)
obj = serialize_entry(entry)
try:
json.dumps(obj)
except Exception as e:
pytest.fail(e)
示例2: serialize_entry
# 需要导入模块: from celery import beat [as 别名]
# 或者: from celery.beat import ScheduleEntry [as 别名]
def serialize_entry(entry):
"""
Serialize ScheduleEntry to json-valid dictionary.
Helps serialize entry to json, yml and any other formats.
:param entry: ScheduleEntry
:return: json-valid dictionary
"""
return {
'name': entry.name,
'task': entry.task,
'schedule': encode_schedule(entry.schedule),
'args': entry.args,
'kwargs': entry.kwargs,
'last_run_at': encode_datetime(entry.last_run_at),
'total_run_count': entry.total_run_count,
'options': entry.options
}
示例3: deserialize_entry
# 需要导入模块: from celery import beat [as 别名]
# 或者: from celery.beat import ScheduleEntry [as 别名]
def deserialize_entry(entry):
"""
Deserialize ScheduleEntry from dictionary.
Helps deserialize entry from json, yml and any other formats.
:param entry:
:return:
"""
return ScheduleEntry(
name=entry['name'],
task=entry['task'],
schedule=decode_schedule(entry['schedule']),
args=entry['args'],
kwargs=entry['kwargs'],
last_run_at=decode_datetime(entry['last_run_at']),
total_run_count=entry['total_run_count'],
options=entry['options'],
)
示例4: setup_schedule
# 需要导入模块: from celery import beat [as 别名]
# 或者: from celery.beat import ScheduleEntry [as 别名]
def setup_schedule(self):
logging.debug("Setting up scheduler")
for entry_name, entry in self.loaded_entries.items():
if isinstance(entry, ScheduleEntry):
self._schedule[entry_name] = BaseScheduleEntry(
name=entry_name,
app=self.app,
task=entry.SCHEDULED_TASK,
schedule=entry.frequency,
args=(str(entry.id),))
示例5: test_entries_save_load
# 需要导入模块: from celery import beat [as 别名]
# 或者: from celery.beat import ScheduleEntry [as 别名]
def test_entries_save_load(self):
entries = {
'entry-1': ScheduleEntry(
name='entry-1',
last_run_at=datetime.utcnow()
),
}
self.store.save_entries(entries)
loaded = self.store.load_entries()
assert entries.keys() == loaded.keys()
示例6: test_serialize_deserialize_entry
# 需要导入模块: from celery import beat [as 别名]
# 或者: from celery.beat import ScheduleEntry [as 别名]
def test_serialize_deserialize_entry(dt):
entry = ScheduleEntry(
name='entry-1',
task='entry-1-task',
schedule=dt,
args=('arg1', 'arg2'),
kwargs={'key1': 'val1', 'key2': 'val2'},
last_run_at=datetime.now(),
total_run_count=1,
options={},
)
decoded_entry = deserialize_entry(serialize_entry(entry))
assert decoded_entry.__reduce__() == entry.__reduce__()