minos.networks.scheduling.schedulers

Classes

PeriodicTask

Periodic Task class.

PeriodicTaskScheduler

Periodic Task Scheduler class.

class PeriodicTaskScheduler[source]

Bases: SetupMixin

Periodic Task Scheduler class.

__init__(tasks, *args, **kwargs)[source]
Parameters

tasks (set[minos.networks.scheduling.schedulers.PeriodicTask]) –

property tasks: set[minos.networks.scheduling.schedulers.PeriodicTask]

Get the set of periodic tasks.

Returns

A set of PeriodicTask instances.

async start()[source]

Start the execution of periodic tasks.

Returns

This method does not return anything.

Return type

None

async stop(timeout=None)[source]

Stop the execution of periodic tasks.

Parameters

timeout (Optional[float]) – An optional timeout expressed in seconds.

Returns

This method does not return anything.

Return type

None

property already_destroyed: bool

Already Destroy getter.

Returns

A boolean value.

property already_setup: bool

Already Setup getter.

Returns

A boolean value.

async destroy()

Destroy miscellaneous repository things.

Returns

This method does not return anything.

Return type

None

classmethod from_config(config=None, **kwargs)

Build a new instance from config.

Parameters
  • config (Optional[Union[Config, Path]]) – Config instance. If None is provided, default config is chosen.

  • kwargs – Additional named arguments.

Returns

A instance of the called class.

Return type

S

async setup()

Setup miscellaneous repository things.

Returns

This method does not return anything.

Return type

None

class PeriodicTask[source]

Bases: object

Periodic Task class.

__init__(crontab, fn)[source]
Parameters
property crontab: minos.networks.scheduling.crontab.CronTab

Get the crontab of the periodic task.

Returns

A CronTab instance.

property fn: Callable[[minos.networks.scheduling.requests.ScheduledRequest], Awaitable[None]]

Get the function to be called periodically.

Returns

A function returning an awaitable.

property started: bool

Check if the periodic task has been started.

Returns

True if started or False otherwise.

property task: _asyncio.Task

Get the asyncio task.

Returns

An asyncio.Task instance.

async start()[source]

Start the periodic task.

Returns

This method does not return anything.

Return type

None

async stop(timeout=None)[source]

Stop the periodic task.

Parameters

timeout (Optional[float]) – An optional timeout expressed in seconds.

Returns

This method does not return anything.

Return type

None

async run_forever()[source]

Run the periodic function forever. This method is equivalent to start, but it keeps waiting until infinite.

Returns

This method never returns.

Return type

NoReturn

property running: bool

Check if the periodic function is running.

Returns

True if it’s running or False otherwise.

async run_once(now=None)[source]

Run the periodic function one time.

Parameters

now (Optional[datetime]) – An optional datetime expressing the current datetime.

Returns

This method does not return anything.

Return type

None