Skip to content

polling

Module to poll different functions.

This module contains function to poll for a specific outcome.

Typical usage example
poll(wait_for=lambda: not is_reload_in_progress(), sleep=2)

T module-attribute

T = typing.TypeVar('T')

poll

poll(target, message=None, wait_for=None, sleep=5)

Polls wait_for callable until it returns True.

Parameters:

  • target (typing.Callable[..., T]) –

    Callable to poll target.

  • message (typing.Optional[typing.Callable[[T], str]]) –

    Callable that takes target return value as input and transforms it to string displayed in progress bar.

  • wait_for (typing.Optional[typing.Callable[[T], bool]]) –

    Callable that takes target return value as input and transforms it to boolean indicating whether polling is finished.

  • sleep (int) –

    Time duration to wait between pools.