Skip to content

tdfs4ds.scheduling.roll_workers

tdfs4ds.scheduling.roll_workers

roll_out(max_workers=N): the processes of one date run in N worker OS processes (0.3.8.0).

A roll_out over D dates and P processes sends its statements one after the other, so on a remote client its wall time is latency-bound. With max_workers the processes of one date that do not depend on each other (same wave of the parallel plan) and do not write the same table (serialize_together) run at the same time, each worker holding its own session. Dates stay sequential and the cursor is moved by the parent between dates, exactly as in the sequential loop.

Workers are separate OS processes (spawn), never threads: run mutates module globals and teradataml shares one connection pool (the reason scheduling/script.py does the same). A worker opens its session from TDFS4DS_TD_* (:func:reconnect_teradata, a LOGDATA token works too).

Pure helpers (units_for, snapshot_settings) are offline-testable.

_SNAPSHOT_SKIP module-attribute

_SNAPSHOT_SKIP = {'RUN_ID', 'FEATURE_STORE_TIME', 'PROCESS_TYPE', 'DISPLAY_LOGS'}

_WORKER module-attribute

_WORKER = {'ready': False}

RollPool

Pool of spawned workers kept for the whole roll-out (each opens its session once).

executor instance-attribute

executor = ProcessPoolExecutor(max_workers=max_workers, mp_context=ctx, initializer=worker_init, initargs=(snapshot_settings(), tdfs4ds.RUN_ID))

__init__

__init__(max_workers)

run_date

run_date(waves, store_time, kwargs)

Run one date; returns {pid: status} of what ran and the first error (or None).

close

close()

snapshot_settings

snapshot_settings() -> dict

The simple module settings of the parent (str / int / float / bool / None / list / dict of those).

_plain

_plain(v)

credentials_available

credentials_available() -> bool

A worker can open its own session: TDFS4DS_TD_* describes a logon (password or token).

units_for

units_for(process_list, plan) -> list

Waves of units from a parallel plan, restricted to process_list.

Returns [[unit, ...], ...]: waves run one after the other; the units of a wave run at the same time; a unit is the list of process ids one worker runs in order (a serialize_together group is one unit). Order inside a unit follows process_list (already in dependency order).

worker_init

worker_init(settings, run_id)

Open this worker's session and apply the parent's settings (called once per worker process).

run_unit

run_unit(pids, store_time, kwargs)

Run pids in order at the business date store_time. Returns [(pid, status, error)]; error is the exception (or its text when it cannot be pickled), None on success. Stops the unit at its first failure, like the sequential loop stops the date.