Skip to content

WeightedWorkScheduler

QuantConnect.Lean.Engine.DataFeeds.WorkScheduling.WeightedWorkScheduler

Bases: WorkScheduler

This singleton class will create a thread pool to processes work that will be prioritized based on it's weight

WORK_BATCH_SIZE

WORK_BATCH_SIZE: int = 50

This is the size of each work sprint

max_work_weight

max_work_weight: int

This is the maximum size a work item can weigh, if reached, it will be ignored and not executed until its less

INSTANCE

Singleton instance

workers_count

workers_count: int = ...

The quantity of workers to be used

add_single_call_for_all

add_single_call_for_all(action: Callable[[], Any]) -> None

Execute the given action in all workers once

queue_work

queue_work(
    symbol: Union[Symbol, str, BaseContract],
    work_func: Callable[[int], bool],
    weight_func: Callable[[], int],
) -> None

Add a new work item to the queue

Parameters:

Name Type Description Default
symbol Union[Symbol, str, BaseContract]

The symbol associated with this work

required
work_func Callable[[int], bool]

The work function to run

required
weight_func Callable[[], int]

The weight function. Work will be sorted in ascending order based on this weight

required