Workers
Background Workers
Background workers run in their own thread allowing cleanup / cron like workers to run in the background, by default flumine adds the following workers:
keep_alive
: runs every 1200s (or session_timeout/2) to make sure clients are logged and kept alivepoll_account_balance
: runs every 120s to poll account balance endpointpoll_market_catalogue
: runs every 60s to poll listMarketCatalogue endpointpoll_market_closure
: checks for closed markets to get cleared orders at order and market level
Variables
flumine
: Frameworkfunction
: Function to be calledinterval
: Interval in seconds, set to None for single callfunc_args
: Function argsfunc_kwargs
: Function kwargsstart_delay
: Start delay in secondscontext
: Worker contextname
: Worker name
Custom Workers
Further workers can be added as per:
from flumine.worker import BackgroundWorker
def func(context: dict, flumine, name=""):
print(name)
worker = BackgroundWorker(
framework, interval=10, function=func, func_args=("hello",)
)
framework.add_worker(
worker
)