Python celery.beat.ScheduleEntry() Examples

The following are 6 code examples of celery.beat.ScheduleEntry(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module celery.beat , or try the search function .
Example #1
Source File: test_serializer.py    From celery-beatx with MIT License 6 votes vote down vote up
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) 
Example #2
Source File: serializer.py    From celery-beatx with MIT License 6 votes vote down vote up
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
    } 
Example #3
Source File: serializer.py    From celery-beatx with MIT License 6 votes vote down vote up
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'],
    ) 
Example #4
Source File: scheduling.py    From yeti with Apache License 2.0 5 votes vote down vote up
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),)) 
Example #5
Source File: test_store.py    From celery-beatx with MIT License 5 votes vote down vote up
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() 
Example #6
Source File: test_serializer.py    From celery-beatx with MIT License 5 votes vote down vote up
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__()