2024-11-03 07:41:11 +00:00
|
|
|
__package__ = 'archivebox.crawls'
|
|
|
|
|
|
|
|
from typing import ClassVar
|
|
|
|
|
|
|
|
from crawls.models import Crawl
|
2024-11-04 15:08:31 +00:00
|
|
|
from crawls.statemachines import CrawlMachine
|
2024-11-03 07:41:11 +00:00
|
|
|
|
2024-11-04 15:08:31 +00:00
|
|
|
from actors.actor import ActorType, State
|
2024-11-03 07:41:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
class CrawlActor(ActorType[Crawl]):
|
2024-11-04 15:08:31 +00:00
|
|
|
"""The Actor that manages the lifecycle of all Crawl objects"""
|
2024-11-03 07:41:11 +00:00
|
|
|
|
2024-11-04 15:08:31 +00:00
|
|
|
Model = Crawl
|
|
|
|
StateMachineClass = CrawlMachine
|
2024-11-03 07:41:11 +00:00
|
|
|
|
2024-11-04 15:08:31 +00:00
|
|
|
ACTIVE_STATE: ClassVar[State] = CrawlMachine.started
|
|
|
|
FINAL_STATES: ClassVar[list[State]] = CrawlMachine.final_states
|
|
|
|
STATE_FIELD_NAME: ClassVar[str] = Crawl.state_field_name
|
2024-11-03 07:41:11 +00:00
|
|
|
|
2024-11-04 15:08:31 +00:00
|
|
|
MAX_CONCURRENT_ACTORS: ClassVar[int] = 3
|
|
|
|
MAX_TICK_TIME: ClassVar[int] = 10
|
|
|
|
CLAIM_FROM_TOP_N: ClassVar[int] = MAX_CONCURRENT_ACTORS * 10
|