Skip to content

KeyStringSynchronizer

QuantConnect.Util.KeyStringSynchronizer

Bases: Object

Helper class to synchronize execution based on a string key

execute

execute(
    key: str,
    single_execution: bool,
    action: Callable[[], Any],
) -> None

Execute the given action synchronously with any other thread using the same key

Parameters:

Name Type Description Default
key str

The synchronization key

required
single_execution bool

True if execution should happen only once at the same time for multiple threads

required
action Callable[[], Any]

The action to execute

required