querypool.pools.threading.ThreadQueryPool#
- class querypool.pools.threading.ThreadQueryPool(timeout=None, maxqueries=None)[source]#
Bases:
QueryPool
This query pool is to be used in an environment that is not gevent patched.
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
])
- 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
- execute(query, args=(), kwargs=None, timeout=None, default=None)[source]#
- Parameters:
query (
Callable
)args (
Optional
[tuple
]) – positional argumentskwargs (
Optional
[dict
]) – named argumentstimeout (
Optional
[float
]) – the timeout of a call before returning/raising the previous resultdefault – 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