querypool


Namequerypool JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://gitlab.esrf.fr/dau/querypool/
SummaryExecution pool with caching and early return
upload_time2024-06-22 11:26:35
maintainerNone
docs_urlNone
authorESRF
requires_python>=3.7
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": null,
    "author": "ESRF",
    "author_email": "wout.de_nolf@esrf.fr",
    "download_url": "https://files.pythonhosted.org/packages/af/0a/4ebaa5c589c22d46ac47d0c76c20eb63046181872e846fc8285133ff66aa/querypool-1.0.0.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": "1.0.0",
    "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": "af0a4ebaa5c589c22d46ac47d0c76c20eb63046181872e846fc8285133ff66aa",
                "md5": "9dda3a53f1fe39808bdaf7cbb50b2a1a",
                "sha256": "2b3172bb4cf938f3e67b1e2d3d9c2468ca63bcee7875b5f8ef85a2d2e0e7154b"
            },
            "downloads": -1,
            "filename": "querypool-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "9dda3a53f1fe39808bdaf7cbb50b2a1a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 7433,
            "upload_time": "2024-06-22T11:26:35",
            "upload_time_iso_8601": "2024-06-22T11:26:35.482250Z",
            "url": "https://files.pythonhosted.org/packages/af/0a/4ebaa5c589c22d46ac47d0c76c20eb63046181872e846fc8285133ff66aa/querypool-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-22 11:26:35",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "querypool"
}
        
Elapsed time: 0.94232s