當前位置: 首頁>>代碼示例>>Python>>正文


Python beat.ScheduleEntry方法代碼示例

本文整理匯總了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) 
開發者ID:mixkorshun,項目名稱:celery-beatx,代碼行數:20,代碼來源:test_serializer.py

示例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
    } 
開發者ID:mixkorshun,項目名稱:celery-beatx,代碼行數:21,代碼來源:serializer.py

示例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'],
    ) 
開發者ID:mixkorshun,項目名稱:celery-beatx,代碼行數:21,代碼來源:serializer.py

示例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),)) 
開發者ID:yeti-platform,項目名稱:yeti,代碼行數:12,代碼來源:scheduling.py

示例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() 
開發者ID:mixkorshun,項目名稱:celery-beatx,代碼行數:15,代碼來源:test_store.py

示例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__() 
開發者ID:mixkorshun,項目名稱:celery-beatx,代碼行數:17,代碼來源:test_serializer.py


注:本文中的celery.beat.ScheduleEntry方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。