Metadata-Version: 2.1
Name: querypool
Version: 0.1.0rc1
Summary: Execution pool with caching and early return
Home-page: https://gitlab.esrf.fr/dau/querypool/
Author: ESRF
Author-email: wout.de_nolf@esrf.fr
License: MIT
Project-URL: Source, https://gitlab.esrf.fr/dau/querypool/
Project-URL: Documentation, https://querypool.readthedocs.io/
Project-URL: Tracker, https://gitlab.esrf.fr/dau/querypool/issues/
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.7
Description-Content-Type: text/markdown
Provides-Extra: test
Provides-Extra: dev
Provides-Extra: doc
License-File: LICENSE.md

# querypool

Execution pool with caching and early return for python.

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.

```
import requests
from querypool.pools import CooperativeQueryPool

pool = CooperativeQueryPool(timeout=0.001)
url = "https://jsonplaceholder.typicode.com/photos"

# Returns None because the query times out.
response = pool.execute(requests.get, args=(url,), default=None)
assert response is None

# Increase the timeout to let the query finish.
# The same function with the same arguments is still running so
# all this does is wait for the result of the previous call.
response = pool.execute(requests.get, args=(url,), default=None, timeout=3)
response.raise_for_status()

# Returns the previous result because the query times out.
response = pool.execute(requests.get, args=(url,), default=None)
response.raise_for_status()
```

## Documentation

https://querypool.readthedocs.io/
