openfl.utilities.fed_timer.SyncAsyncTaskDecoFactory

class openfl.utilities.fed_timer.SyncAsyncTaskDecoFactory

Bases: object

Sync and Async Task decorator factory.

This class is a factory for creating decorators for synchronous and asynchronous tasks. Task decorator factory allows creation of concrete implementation of wrapper interface and contextmanager to setup a common functionality/resources shared by async_wrapper and sync_wrapper.

Class Attributes:

is_coroutine (bool) – Whether the decorated function is a coroutine.

Methods

wrapper

Create a context for the decorated function.

__call__(func)

Decorate the function. Call to @fedtiming() executes __call__() method delegated from the derived class fedtiming implementing SyncAsyncTaskDecoFactory.

Parameters:

func (function) – The function to be decorated.

Returns:

function – The decorated function.

wrapper(func, *args, **kwargs)

Create a context for the decorated function.

Parameters:
  • func (function) – The function to be decorated.

  • args (tuple) – The positional arguments to pass to the function.

  • kwargs (dict) – The keyword arguments to pass to the function.

Yields:

None