# 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/
Raw data
{
"_id": null,
"home_page": "https://gitlab.esrf.fr/dau/querypool/",
"name": "querypool",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "",
"author": "ESRF",
"author_email": "wout.de_nolf@esrf.fr",
"download_url": "https://files.pythonhosted.org/packages/2f/b2/38339a954318e5ea625b453778865b38a8fb8c1374e53d3031c69b71db8b/querypool-0.1.0rc2.tar.gz",
"platform": null,
"description": "# querypool\n\nExecution pool with caching and early return for python.\n\nQuery pools let a query run in the background when it doesn't return\nwithin a given timeout. In that case the result of the previous query\nis returned or raised. If there is no result, the default value is returned.\n\n```\nimport requests\nfrom querypool.pools import CooperativeQueryPool\n\npool = CooperativeQueryPool(timeout=0.001)\nurl = \"https://jsonplaceholder.typicode.com/photos\"\n\n# Returns None because the query times out.\nresponse = pool.execute(requests.get, args=(url,), default=None)\nassert response is None\n\n# Increase the timeout to let the query finish.\n# The same function with the same arguments is still running so\n# all this does is wait for the result of the previous call.\nresponse = pool.execute(requests.get, args=(url,), default=None, timeout=3)\nresponse.raise_for_status()\n\n# Returns the previous result because the query times out.\nresponse = pool.execute(requests.get, args=(url,), default=None)\nresponse.raise_for_status()\n```\n\n## Documentation\n\nhttps://querypool.readthedocs.io/\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Execution pool with caching and early return",
"version": "0.1.0rc2",
"project_urls": {
"Documentation": "https://querypool.readthedocs.io/",
"Homepage": "https://gitlab.esrf.fr/dau/querypool/",
"Source": "https://gitlab.esrf.fr/dau/querypool/",
"Tracker": "https://gitlab.esrf.fr/dau/querypool/issues/"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "2fb238339a954318e5ea625b453778865b38a8fb8c1374e53d3031c69b71db8b",
"md5": "c89027226b201eb51f35f3ed910db876",
"sha256": "182a1d47d94cd6cf0d595f66d0d0dd434f5e4068e7784729369004813e6128e2"
},
"downloads": -1,
"filename": "querypool-0.1.0rc2.tar.gz",
"has_sig": false,
"md5_digest": "c89027226b201eb51f35f3ed910db876",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 6864,
"upload_time": "2024-01-20T16:47:38",
"upload_time_iso_8601": "2024-01-20T16:47:38.500538Z",
"url": "https://files.pythonhosted.org/packages/2f/b2/38339a954318e5ea625b453778865b38a8fb8c1374e53d3031c69b71db8b/querypool-0.1.0rc2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-20 16:47:38",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "querypool"
}