archivebox.workers.models
Module Contents
Classes
Data
API
- archivebox.workers.models.default_retry_at_field: django.db.models.DateTimeField[source]
‘DateTimeField(…)’
- class archivebox.workers.models.BaseModelWithStateMachine[source]
Bases:
django.db.models.Model
,statemachine.mixins.MachineMixin
- static _state_to_str(state: archivebox.workers.models.ObjectState) str [source]
Convert a statemachine.State, models.TextChoices.choices value, or Enum value to a str
- classmethod extend_choices(base_choices: Type[django.db.models.TextChoices])[source]
Decorator to extend the base choices with extra choices, e.g.:
class MyModel(ModelWithStateMachine):
@ModelWithStateMachine.extend_choices(ModelWithStateMachine.StatusChoices) class StatusChoices(models.TextChoices): SUCCEEDED = 'succeeded' FAILED = 'failed' SKIPPED = 'skipped'
- classmethod StatusField(**kwargs) django.db.models.CharField [source]
Used on subclasses to extend/modify the status field with updated kwargs. e.g.:
class MyModel(ModelWithStateMachine): class StatusChoices(ModelWithStateMachine.StatusChoices): QUEUED = ‘queued’, ‘Queued’ STARTED = ‘started’, ‘Started’ SEALED = ‘sealed’, ‘Sealed’ BACKOFF = ‘backoff’, ‘Backoff’ FAILED = ‘failed’, ‘Failed’ SKIPPED = ‘skipped’, ‘Skipped’
status = ModelWithStateMachine.StatusField(choices=StatusChoices.choices, default=StatusChoices.QUEUED)
- class archivebox.workers.models.ModelWithStateMachine[source]
Bases:
archivebox.workers.models.BaseModelWithStateMachine
- StatusChoices: ClassVar[Type[archivebox.workers.models.DefaultStatusChoices]][source]
None
- class archivebox.workers.models.EventQuerySet[source]
Bases:
django.db.models.QuerySet
- expired(older_than: int = 60 * 10) django.db.models.QuerySet[archivebox.workers.models.Event] [source]
- class archivebox.workers.models.Event(*args: Any, **kwargs: Any)[source]
Bases:
base_models.models.ABIDModel
- read_only_fields[source]
(‘id’, ‘deliver_at’, ‘name’, ‘kwargs’, ‘timeout’, ‘parent’, ‘emitted_by’, ‘on_success’, ‘on_failure’…
- objects: archivebox.workers.models.EventManager[source]
‘(…)’
- child_events: django.db.models.RelatedManager[archivebox.workers.models.Event][source]
None
- classmethod get_next_timestamp()[source]
Get the next monotonically increasing timestamp for the next event.dispatch_at
- classmethod dispatch(name: str | archivebox.workers.models.EventDict | None = None, event: archivebox.workers.models.EventDict | None = None, **event_init_kwargs) archivebox.workers.models.Event [source]
Create a new Event and save it to the database.
Can be called as either: >>> Event.dispatch(name, {**kwargs}, **event_init_kwargs) # OR >>> Event.dispatch({name, **kwargs}, **event_init_kwargs)
- reset()[source]
Force-update an event to a pending/unclaimed state (without running any of its handlers or callbacks)