querypool.pools.interface.QueryPool#

class querypool.pools.interface.QueryPool(timeout=None, maxqueries=None)[source]#

Bases: ABC

Query pools let a query run in the background when it doesn’t return within a given timeout. In that case the result of the previous query is returned or raised. If there is no result, the default value is returned.

Parameters:
  • timeout (Optional[float])

  • maxqueries (Optional[int])

abstractmethod cancel(timeout=None, block=True)[source]#
Parameters:
  • block

  • timeout – only applies when block=True

Return type:

Optional[bool]

Returns:

None when block=False, True when all queries are cancelled and False otherwise

abstractmethod execute(query, args=(), kwargs=None, timeout=None, default=None)[source]#
Parameters:
  • query (Callable)

  • args (Optional[tuple]) – positional arguments

  • kwargs (Optional[dict]) – named arguments

  • timeout (Optional[float]) – the timeout of a call before returning/raising the previous result

  • default – the default value in case there is no previous result

Return type:

Any

Returns:

the result of the query or the default value

Raises:

the exception from the query

abstractmethod wait(timeout=None)[source]#
Parameters:

timeout

Return type:

bool

Returns:

True when all queries finished, False otherwise