cachelib
cachelib copied to clipboard
use ClientPool to prevent race conditions when using pylibmc as memcached package
This patch aims to fix concurrency issues when using the gthread
worker class in gunicorn in combination with the pylibmc
Memcached backend by utilizing a ClientPool
rather than a single Client
. This issue was also (partially) detailed in https://github.com/pallets-eco/flask-caching/issues/113.
The proposed solution should work for every gunicorn worker configuration, so this patch always uses a ClientPool
in an attempt to not further complicate the code with unnecessary branching statements. If you prefer it otherwise, I can still change that using a configuration switch.
Note that this patch also requires some changes to the flask-caching
repository, but I first want to iterate on it here before opening another PR in that repository.
Checklist:
- [ ] Add tests that demonstrate the correct behavior of the change. Tests should fail without the change.
- [ ] Add or update relevant docs, in the docs folder and in code.
- [ ] Add an entry in
CHANGES.rst
summarizing the change and linking to the issue. - [ ] Add
.. versionchanged::
entries in any relevant code docs. - [x] Run
pre-commit
hooks and fix any issues. - [ ] Run
pytest
andtox
, no tests failed.