Tasks

class yasmon.tasks.TaskRunner(tasks: TaskList, testenv: bool = False)

Asyncio loop handler. Acts as a functor.

async signal_handler(sig: Signals)

Signal handler.

async cancle_tasks(delay=2)

Cancle tasks (for testing purposes)

class yasmon.tasks.TaskList(iterable: list[yasmon.tasks.AbstractTask] | None = None)

A dedicated list for tasks.

class yasmon.tasks.WatchfilesTask(name: str, changes: list[watchfiles.main.Change], callbacks: list[yasmon.callbacks.AbstractCallback], paths: list[str], timeout: int, max_retry: int, attrs: dict[str, str] | None = None)
__init__(name: str, changes: list[watchfiles.main.Change], callbacks: list[yasmon.callbacks.AbstractCallback], paths: list[str], timeout: int, max_retry: int, attrs: dict[str, str] | None = None) None
Parameters:
  • name – unique identifier

  • changes – list of watchfiles events

  • callbacks – assigned callbacks

  • paths – paths to watch (files/directories)

  • attrs – (static) attributes

async awatch_loop(callback)
classmethod from_yaml(name: str, data: str, callbacks: list[yasmon.callbacks.AbstractCallback]) Self

WatchfilesTask can be also constructed from a YAML snippet.

changes:
    - added
callbacks:
    - callback0
paths:
    - /some/path/to/file1
    - /some/path/to/file2
attrs:
    myattr: value
timeout: 10
max_retry: 3

Possible changes are added, modified and deleted.

Parameters:
  • name – unique identifier

  • data – YAML snippet

  • callbacks – list of associated callbacks

Returns:

new instance

Return type:

WatchfilesTask

class yasmon.tasks.AbstractTask

Abstract class from which all task classes are derived.

Derived tasks are functors calling the assigned callback coroutine and can be used for yasmon.tasks.TaskRunner.

The preferred way to instatiate a task is from class method from_yaml().

abstract async __call__(callback: AbstractCallback)

Coroutine called by TaskRunner.

abstract classmethod from_yaml(name: str, data: str, callbacks: list[yasmon.callbacks.AbstractCallback])

A class method for constructing a callback from a YAML document.

Parameters:
  • name – unique identifier

  • data – yaml data

  • callbacks – collection of callbacks

Returns:

new instance