databay.base_planner

See also

Extending BasePlanner to learn how to extend this class correctly.

class databay.base_planner.BasePlanner(links: Union[Link, List[Link]] = None, ignore_exceptions: bool = False, immediate_transfer: bool = True, shutdown_at_exit: bool = False)[source]

databay.base_planner.BasePlanner

Base abstract class for a job planner. Implementations should handle scheduling link transfers based on datetime.timedelta intervals.

Parameters
  • links (Link or list[Link]) – Links that should be added and scheduled.

  • ignore_exceptions (bool) – Whether exceptions should be ignored, or halt the planner.

    Default:
    False

  • immediate_transfer (bool) – Whether this planner should execute transfer once immediately upon starting for all links that have Link.immediate_transfer set to True.

    Default:
    True

  • shutdown_at_exit (bool) – Whether this planner should attempt to gracefully shutdown if the app exists unexpectedly.

    Default:
    False

Bases: abc.ABC

property

Links currently handled by this planner.

Returns

list[Link]

Add new links to this planner. This can be run once planner is already running.

Parameters

links (Link or list[Link]) – Links that should be added and scheduled.

Remove links from this planner. This can be run once planner is already running.

Parameters

links (Link or list[Link]) – Links that should be unscheduled and removed.

Raises

MissingLinkError if link is not found.

start(self)[source]

Start this planner. Links will start being scheduled based on their intervals after calling this method. The exact methodology depends on the planner implementation used.

This will also loop over all links and call the on_start callback before starting the planner.

If BasePlanner.immediate_transfer is set to True, this function will additionally call Link.transfer once for each link managed by this planner before starting.

See Start and Shutdown to learn more about starting and shutdown.

shutdown(self, wait: bool = True)[source]

Shutdown this planner. Links will stop being scheduled after calling this method. Remaining link jobs may still execute after calling this method depending on the concrete planner implementation.

This will also loop over all links and call the on_shutdown callback after shutting down the planner.

See Start and Shutdown to learn more about starting and shutdown.

purge(self)[source]

Unschedule and clear all links. It can be used while planner is running.

running(self)[source]

property

Whether this planner is currently running.

By default always returns True.

Override this property to indicate when the underlying scheduling functionality is currently running.

force_transfer(self)[source]

Immediately force a transfer on all Links governed by this planner.