本文整理匯總了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__()