Repository navigation
Add a backend for Valkey - #9300
amirreza-sf80 wants to merge 15 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9300 +/- ##
==========================================
+ Coverage 78.50% 78.52% +0.02%
==========================================
Files 153 155 +2
Lines 19127 19159 +32
Branches 2533 2535 +2
==========================================
+ Hits 15015 15044 +29
Misses 3820 3820
- Partials 292 295 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
Nusnus
left a comment
There was a problem hiding this comment.
If I understand correctly, Valkey is a Redis replacement that for the time being works the same, literally, using the same API in the new package.
Shouldn't we add integration tests as well then?
I'm also considering developing support for pytest-celery, but the integration tests will need to come first IMHO.
Nusnus
left a comment
There was a problem hiding this comment.
I'd also recommend renaming the PR to something more meaningful for the sake of clear changelog.
|
hi about the tests, if someone else want's to do it it's fine by me, but if not, i need a bit of time to see how integration tests are set up, either way i'm good |
|
@amirreza8002
I’ve added integration tests to the PR. When I run it locally, I get an error from one of the tests: Steps to reproduce
docker start rabbitmq valkey && tox -e 3.12-integration-rabbitmq_valkey && docker stop rabbitmq valkey
rabbitmq
valkey
ROOT: will run in automatically provisioned tox, host /opt/homebrew/Cellar/tox/4.20.0/libexec/bin/python is missing [requires (has)]: tox-gh-actions
ROOT: provision> .tox/.tox/bin/python -m tox -e 3.12-integration-rabbitmq_valkey
ROOT: tox-gh-actions won't override envlist because tox is not running in GitHub Actions
3.12-integration-rabbitmq_valkey: install_deps> python -I -m pip install -r /Users/nusnus/dev/GitHub/celery/requirements/test.txt -r /Users/nusnus/dev/GitHub/celery/requirements/pkgutils.txt -r /Users/nusnus/dev/GitHub/celery/requirements/test-ci-default.txt -r /Users/nusnus/dev/GitHub/celery/requirements/docs.txt -r /Users/nusnus/dev/GitHub/celery/requirements/test-integration.txt
.pkg: _optional_hooks> python /Users/nusnus/dev/GitHub/celery/.tox/.tox/lib/python3.12/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
.pkg: get_requires_for_build_editable> python /Users/nusnus/dev/GitHub/celery/.tox/.tox/lib/python3.12/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
.pkg: build_editable> python /Users/nusnus/dev/GitHub/celery/.tox/.tox/lib/python3.12/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
3.12-integration-rabbitmq_valkey: install_package> python -I -m pip install --force-reinstall --no-deps /Users/nusnus/dev/GitHub/celery/.tox/.tmp/package/9/celery-5.5.0b3-0.editable-py3-none-any.whl
3.12-integration-rabbitmq_valkey: commands[0]> pytest -xsvv t/integration
======================================================================================= test session starts =======================================================================================
platform darwin -- Python 3.12.6, pytest-8.3.3, pluggy-1.5.0 -- /Users/nusnus/dev/GitHub/celery/.tox/3.12-integration-rabbitmq_valkey/bin/python
cachedir: .tox/3.12-integration-rabbitmq_valkey/.pytest_cache
rootdir: /Users/nusnus/dev/GitHub/celery
configfile: pyproject.toml
plugins: docker-tools-3.1.3, cov-5.0.0, github-actions-annotate-failures-0.2.0, click-1.1.0, celery-1.1.3, anyio-4.6.0, rerunfailures-14.0, order-1.3.0, subtests-0.13.1, timeout-2.3.1
collected 227 items
t/integration/test_backend.py::test_AzureBlockBlobBackend::test_crud SKIPPED (Environment variable AZUREBLOCKBLOB_URL required)
t/integration/test_backend.py::test_AzureBlockBlobBackend::test_get_missing SKIPPED (Environment variable AZUREBLOCKBLOB_URL required)
t/integration/test_canvas.py::test_link_error::test_link_error_eager PASSED
t/integration/test_canvas.py::test_link_error::test_link_error PASSED
t/integration/test_canvas.py::test_link_error::test_link_error_callback_error_callback_retries_eager PASSED
t/integration/test_canvas.py::test_link_error::test_link_error_callback_retries PASSED
t/integration/test_canvas.py::test_link_error::test_link_error_using_signature_eager PASSED
t/integration/test_canvas.py::test_link_error::test_link_error_using_signature PASSED
t/integration/test_canvas.py::test_chain::test_simple_chain PASSED
t/integration/test_canvas.py::test_chain::test_single_chain PASSED
t/integration/test_canvas.py::test_chain::test_complex_chain PASSED
t/integration/test_canvas.py::test_chain::test_group_results_in_chain XFAIL (Task is timeout)
t/integration/test_canvas.py::test_chain::test_chain_of_chain_with_a_single_task PASSED
t/integration/test_canvas.py::test_chain::test_chain_on_error SKIPPED (Requires redis result backend.)
t/integration/test_canvas.py::test_chain::test_chain_inside_group_receives_arguments PASSED
t/integration/test_canvas.py::test_chain::test_eager_chain_inside_task PASSED
t/integration/test_canvas.py::test_chain::test_group_chord_group_chain SKIPPED (Requires redis result backend.)
t/integration/test_canvas.py::test_chain::test_group_result_not_has_cache PASSED
t/integration/test_canvas.py::test_chain::test_second_order_replace SKIPPED (Requires redis result backend.)
t/integration/test_canvas.py::test_chain::test_parent_ids PASSED
t/integration/test_canvas.py::test_chain::test_chord_soft_timeout_recuperation SKIPPED (Requires redis result backend.)
t/integration/test_canvas.py::test_chain::test_chain_error_handler_with_eta PASSED
t/integration/test_canvas.py::test_chain::test_groupresult_serialization PASSED
t/integration/test_canvas.py::test_chain::test_chain_of_task_a_group_and_a_chord PASSED
t/integration/test_canvas.py::test_chain::test_chain_of_chords_as_groups_chained_to_a_task_with_two_tasks PASSED
t/integration/test_canvas.py::test_chain::test_chain_of_chords_with_two_tasks PASSED
t/integration/test_canvas.py::test_chain::test_chain_of_a_chord_and_a_group_with_two_tasks PASSED
t/integration/test_canvas.py::test_chain::test_chain_of_a_chord_and_a_task_and_a_group PASSED
t/integration/test_canvas.py::test_chain::test_chain_of_a_chord_and_two_tasks_and_a_group PASSED
t/integration/test_canvas.py::test_chain::test_chain_of_a_chord_and_three_tasks_and_a_group PASSED
t/integration/test_canvas.py::test_chain::test_nested_chain_group_lone XFAIL (Task is timeout)
t/integration/test_canvas.py::test_chain::test_nested_chain_group_mid PASSED
t/integration/test_canvas.py::test_chain::test_nested_chain_group_last PASSED
t/integration/test_canvas.py::test_chain::test_chain_replaced_with_a_chain_and_a_callback SKIPPED (Requires redis result backend.)
t/integration/test_canvas.py::test_chain::test_chain_replaced_with_a_chain_and_an_error_callback SKIPPED (Requires redis result backend.)
t/integration/test_canvas.py::test_chain::test_chain_with_cb_replaced_with_chain_with_cb SKIPPED (Requires redis result backend.)
t/integration/test_canvas.py::test_chain::test_chain_flattening_keep_links_of_inner_chain SKIPPED (Requires redis result backend.)
t/integration/test_canvas.py::test_chain::test_chain_with_eb_replaced_with_chain_with_eb SKIPPED (Requires redis result backend.)
t/integration/test_canvas.py::test_chain::test_replace_chain_with_empty_chain FAILED
============================================================================================ FAILURES =============================================================================================
_________________________________________________________________________ test_chain.test_replace_chain_with_empty_chain __________________________________________________________________________
self = <t.integration.test_canvas.test_chain object at 0x1292cc3e0>, manager = <celery.contrib.testing.manager.Manager object at 0x12c17cfe0>
def test_replace_chain_with_empty_chain(self, manager):
r = chain(identity.s(1), replace_with_empty_chain.s()).delay()
with pytest.raises(ImproperlyConfigured,
match="Cannot replace with an empty chain"):
> r.get(timeout=TIMEOUT)
t/integration/test_canvas.py:659:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
celery/result.py:251: in get
return self.backend.wait_for_pending(
celery/backends/asynchronous.py:221: in wait_for_pending
for _ in self._wait_for_pending(result, **kwargs):
celery/backends/asynchronous.py:287: in _wait_for_pending
for _ in self.drain_events_until(
celery/backends/asynchronous.py:54: in drain_events_until
yield self.wait_for(p, wait, timeout=interval)
celery/backends/asynchronous.py:63: in wait_for
wait(timeout=timeout)
celery/backends/redis.py:161: in drain_events
message = self._pubsub.get_message(timeout=timeout)
.tox/3.12-integration-rabbitmq_valkey/lib/python3.12/site-packages/valkey/client.py:1072: in get_message
response = self.parse_response(block=(timeout is None), timeout=timeout)
.tox/3.12-integration-rabbitmq_valkey/lib/python3.12/site-packages/valkey/client.py:883: in parse_response
response = self._execute(conn, try_read)
.tox/3.12-integration-rabbitmq_valkey/lib/python3.12/site-packages/valkey/client.py:859: in _execute
return conn.retry.call_with_retry(
.tox/3.12-integration-rabbitmq_valkey/lib/python3.12/site-packages/valkey/retry.py:62: in call_with_retry
return do()
.tox/3.12-integration-rabbitmq_valkey/lib/python3.12/site-packages/valkey/client.py:860: in <lambda>
lambda: command(*args, **kwargs),
.tox/3.12-integration-rabbitmq_valkey/lib/python3.12/site-packages/valkey/client.py:881: in try_read
return conn.read_response(disconnect_on_error=False, push_request=True)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <valkey.connection.Connection(host=localhost,port=6379,db=0)>, disable_decoding = False
def read_response(
self,
disable_decoding=False,
*,
disconnect_on_error=True,
push_request=False,
):
"""Read the response from a previously sent command"""
host_error = self._host_error()
try:
if self.protocol in ["3", 3] and not LIBVALKEY_AVAILABLE:
response = self._parser.read_response(
disable_decoding=disable_decoding, push_request=push_request
)
else:
response = self._parser.read_response(disable_decoding=disable_decoding)
except socket.timeout:
if disconnect_on_error:
self.disconnect()
raise TimeoutError(f"Timeout reading from {host_error}")
except OSError as e:
if disconnect_on_error:
self.disconnect()
raise ConnectionError(
f"Error while reading from {host_error}" f" : {e.args}"
)
except BaseException:
# Also by default close in case of BaseException. A lot of code
# relies on this behaviour when doing Command/Response pairs.
# See #1128.
if disconnect_on_error:
self.disconnect()
raise
if self.health_check_interval:
self.next_health_check = time() + self.health_check_interval
if isinstance(response, ResponseError):
try:
> raise response
E valkey.exceptions.ResponseError: NOSUB 'unsubscribe' command executed not in subscribed mode
.tox/3.12-integration-rabbitmq_valkey/lib/python3.12/site-packages/valkey/connection.py:570: ResponseError
---------------------------------------------------------------------------------------- Captured log call ----------------------------------------------------------------------------------------
INFO celery.worker.strategy:strategy.py:161 Task t.integration.tasks.identity[fba9edad-7d68-4b3c-bf94-74e6a1d9b61f] received
INFO celery.app.trace:trace.py:128 Task t.integration.tasks.identity[fba9edad-7d68-4b3c-bf94-74e6a1d9b61f] succeeded in 0.0011258750018896535s: 1
======================================================================================== warnings summary =========================================================================================
t/integration/test_canvas.py::test_chain::test_chain_error_handler_with_eta
/Users/nusnus/dev/GitHub/celery/celery/canvas.py:2301: CPendingDeprecationWarning: task_allow_error_cb_on_chord_header=False is pending deprecation in a future release of Celery.
Please test the new behavior by setting task_allow_error_cb_on_chord_header to True and report any concerns you might have in our issue tracker before we make a final decision regarding how errbacks should behave when used with chords.
warnings.warn(
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
===================================================================================== short test summary info =====================================================================================
FAILED t/integration/test_canvas.py::test_chain::test_replace_chain_with_empty_chain - valkey.exceptions.ResponseError: NOSUB 'unsubscribe' command executed not in subscribed mode
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
============================================================ 1 failed, 25 passed, 11 skipped, 2 xfailed, 1 warning in 72.59s (0:01:12) ============================================================
Exception ignored in: <function AsyncResult.__del__ at 0x1281a7f60>
Traceback (most recent call last):
File "/Users/nusnus/dev/GitHub/celery/celery/result.py", line 417, in __del__
File "/Users/nusnus/dev/GitHub/celery/celery/backends/asynchronous.py", line 208, in remove_pending_result
File "/Users/nusnus/dev/GitHub/celery/celery/backends/asynchronous.py", line 216, in on_result_fulfilled
File "/Users/nusnus/dev/GitHub/celery/celery/backends/redis.py", line 184, in cancel_for
File "/Users/nusnus/dev/GitHub/celery/.tox/3.12-integration-rabbitmq_valkey/lib/python3.12/site-packages/valkey/client.py", line 1000, in unsubscribe
File "/Users/nusnus/dev/GitHub/celery/.tox/3.12-integration-rabbitmq_valkey/lib/python3.12/site-packages/valkey/client.py", line 804, in execute_command
File "/Users/nusnus/dev/GitHub/celery/.tox/3.12-integration-rabbitmq_valkey/lib/python3.12/site-packages/valkey/connection.py", line 1107, in get_connection
File "/Users/nusnus/dev/GitHub/celery/.tox/3.12-integration-rabbitmq_valkey/lib/python3.12/site-packages/valkey/connection.py", line 314, in connect
File "/Users/nusnus/dev/GitHub/celery/.tox/3.12-integration-rabbitmq_valkey/lib/python3.12/site-packages/valkey/connection.py", line 345, in on_connect
File "/Users/nusnus/dev/GitHub/celery/.tox/3.12-integration-rabbitmq_valkey/lib/python3.12/site-packages/valkey/_parsers/libvalkey.py", line 51, in on_connect
ImportError: sys.meta_path is None, Python is likely shutting down
Exception ignored in: <function AsyncResult.__del__ at 0x1281a7f60>
Traceback (most recent call last):
File "/Users/nusnus/dev/GitHub/celery/celery/result.py", line 417, in __del__
File "/Users/nusnus/dev/GitHub/celery/celery/backends/asynchronous.py", line 208, in remove_pending_result
File "/Users/nusnus/dev/GitHub/celery/celery/backends/asynchronous.py", line 216, in on_result_fulfilled
File "/Users/nusnus/dev/GitHub/celery/celery/backends/redis.py", line 184, in cancel_for
File "/Users/nusnus/dev/GitHub/celery/.tox/3.12-integration-rabbitmq_valkey/lib/python3.12/site-packages/valkey/client.py", line 1000, in unsubscribe
File "/Users/nusnus/dev/GitHub/celery/.tox/3.12-integration-rabbitmq_valkey/lib/python3.12/site-packages/valkey/client.py", line 804, in execute_command
File "/Users/nusnus/dev/GitHub/celery/.tox/3.12-integration-rabbitmq_valkey/lib/python3.12/site-packages/valkey/connection.py", line 1120, in get_connection
File "/Users/nusnus/dev/GitHub/celery/.tox/3.12-integration-rabbitmq_valkey/lib/python3.12/site-packages/valkey/connection.py", line 314, in connect
File "/Users/nusnus/dev/GitHub/celery/.tox/3.12-integration-rabbitmq_valkey/lib/python3.12/site-packages/valkey/connection.py", line 345, in on_connect
File "/Users/nusnus/dev/GitHub/celery/.tox/3.12-integration-rabbitmq_valkey/lib/python3.12/site-packages/valkey/_parsers/libvalkey.py", line 51, in on_connect
ImportError: sys.meta_path is None, Python is likely shutting down
3.12-integration-rabbitmq_valkey: exit 1 (73.34 seconds) /Users/nusnus/dev/GitHub/celery> pytest -xsvv t/integration pid=62015
3.12-integration-rabbitmq_valkey: FAIL code 1 (79.53=setup[6.19]+cmd[73.34] seconds)
evaluation failed :( (79.89 seconds) |
I’ve changed the port to avoid conflicts with Redis.
Still gives the same error: docker start rabbitmq valkey && tox -e 3.12-integration-rabbitmq_valkey && docker stop rabbitmq valkey
rabbitmq
valkey
ROOT: will run in automatically provisioned tox, host /opt/homebrew/Cellar/tox/4.20.0/libexec/bin/python is missing [requires (has)]: tox-gh-actions
ROOT: provision> .tox/.tox/bin/python -m tox -e 3.12-integration-rabbitmq_valkey
ROOT: tox-gh-actions won't override envlist because tox is not running in GitHub Actions
.pkg: _optional_hooks> python /Users/nusnus/dev/GitHub/celery/.tox/.tox/lib/python3.12/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
.pkg: get_requires_for_build_editable> python /Users/nusnus/dev/GitHub/celery/.tox/.tox/lib/python3.12/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
.pkg: build_editable> python /Users/nusnus/dev/GitHub/celery/.tox/.tox/lib/python3.12/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
3.12-integration-rabbitmq_valkey: install_package> python -I -m pip install --force-reinstall --no-deps /Users/nusnus/dev/GitHub/celery/.tox/.tmp/package/10/celery-5.5.0b3-0.editable-py3-none-any.whl
3.12-integration-rabbitmq_valkey: commands[0]> pytest -xsvv t/integration
======================================================================================= test session starts =======================================================================================
platform darwin -- Python 3.12.6, pytest-8.3.3, pluggy-1.5.0 -- /Users/nusnus/dev/GitHub/celery/.tox/3.12-integration-rabbitmq_valkey/bin/python
cachedir: .tox/3.12-integration-rabbitmq_valkey/.pytest_cache
rootdir: /Users/nusnus/dev/GitHub/celery
configfile: pyproject.toml
plugins: docker-tools-3.1.3, cov-5.0.0, github-actions-annotate-failures-0.2.0, click-1.1.0, celery-1.1.3, anyio-4.6.0, rerunfailures-14.0, order-1.3.0, subtests-0.13.1, timeout-2.3.1
collected 227 items
t/integration/test_backend.py::test_AzureBlockBlobBackend::test_crud SKIPPED (Environment variable AZUREBLOCKBLOB_URL required)
t/integration/test_backend.py::test_AzureBlockBlobBackend::test_get_missing SKIPPED (Environment variable AZUREBLOCKBLOB_URL required)
t/integration/test_canvas.py::test_link_error::test_link_error_eager PASSED
t/integration/test_canvas.py::test_link_error::test_link_error PASSED
t/integration/test_canvas.py::test_link_error::test_link_error_callback_error_callback_retries_eager PASSED
t/integration/test_canvas.py::test_link_error::test_link_error_callback_retries PASSED
t/integration/test_canvas.py::test_link_error::test_link_error_using_signature_eager PASSED
t/integration/test_canvas.py::test_link_error::test_link_error_using_signature PASSED
t/integration/test_canvas.py::test_chain::test_simple_chain PASSED
t/integration/test_canvas.py::test_chain::test_single_chain PASSED
t/integration/test_canvas.py::test_chain::test_complex_chain PASSED
t/integration/test_canvas.py::test_chain::test_group_results_in_chain XFAIL (Task is timeout)
t/integration/test_canvas.py::test_chain::test_chain_of_chain_with_a_single_task PASSED
t/integration/test_canvas.py::test_chain::test_chain_on_error SKIPPED (Requires redis result backend.)
t/integration/test_canvas.py::test_chain::test_chain_inside_group_receives_arguments PASSED
t/integration/test_canvas.py::test_chain::test_eager_chain_inside_task PASSED
t/integration/test_canvas.py::test_chain::test_group_chord_group_chain SKIPPED (Requires redis result backend.)
t/integration/test_canvas.py::test_chain::test_group_result_not_has_cache PASSED
t/integration/test_canvas.py::test_chain::test_second_order_replace SKIPPED (Requires redis result backend.)
t/integration/test_canvas.py::test_chain::test_parent_ids PASSED
t/integration/test_canvas.py::test_chain::test_chord_soft_timeout_recuperation SKIPPED (Requires redis result backend.)
t/integration/test_canvas.py::test_chain::test_chain_error_handler_with_eta PASSED
t/integration/test_canvas.py::test_chain::test_groupresult_serialization PASSED
t/integration/test_canvas.py::test_chain::test_chain_of_task_a_group_and_a_chord PASSED
t/integration/test_canvas.py::test_chain::test_chain_of_chords_as_groups_chained_to_a_task_with_two_tasks PASSED
t/integration/test_canvas.py::test_chain::test_chain_of_chords_with_two_tasks PASSED
t/integration/test_canvas.py::test_chain::test_chain_of_a_chord_and_a_group_with_two_tasks PASSED
t/integration/test_canvas.py::test_chain::test_chain_of_a_chord_and_a_task_and_a_group PASSED
t/integration/test_canvas.py::test_chain::test_chain_of_a_chord_and_two_tasks_and_a_group PASSED
t/integration/test_canvas.py::test_chain::test_chain_of_a_chord_and_three_tasks_and_a_group PASSED
t/integration/test_canvas.py::test_chain::test_nested_chain_group_lone XFAIL (Task is timeout)
t/integration/test_canvas.py::test_chain::test_nested_chain_group_mid PASSED
t/integration/test_canvas.py::test_chain::test_nested_chain_group_last PASSED
t/integration/test_canvas.py::test_chain::test_chain_replaced_with_a_chain_and_a_callback SKIPPED (Requires redis result backend.)
t/integration/test_canvas.py::test_chain::test_chain_replaced_with_a_chain_and_an_error_callback SKIPPED (Requires redis result backend.)
t/integration/test_canvas.py::test_chain::test_chain_with_cb_replaced_with_chain_with_cb SKIPPED (Requires redis result backend.)
t/integration/test_canvas.py::test_chain::test_chain_flattening_keep_links_of_inner_chain SKIPPED (Requires redis result backend.)
t/integration/test_canvas.py::test_chain::test_chain_with_eb_replaced_with_chain_with_eb SKIPPED (Requires redis result backend.)
t/integration/test_canvas.py::test_chain::test_replace_chain_with_empty_chain PASSED
t/integration/test_canvas.py::test_chain::test_chain_children_with_callbacks SKIPPED (Requires redis result backend.)
t/integration/test_canvas.py::test_chain::test_chain_children_with_errbacks SKIPPED (Requires redis result backend.)
t/integration/test_canvas.py::test_chain::test_chain_with_callback_child_replaced SKIPPED (Requires redis result backend.)
t/integration/test_canvas.py::test_chain::test_chain_with_errback_child_replaced SKIPPED (Requires redis result backend.)
t/integration/test_canvas.py::test_chain::test_chain_child_with_callback_replaced SKIPPED (Requires redis result backend.)
t/integration/test_canvas.py::test_chain::test_chain_child_with_errback_replaced SKIPPED (Requires redis result backend.)
t/integration/test_canvas.py::test_chain::test_task_replaced_with_chain XPASS (Task is timeout instead of returning exception on rpc backend)
t/integration/test_canvas.py::test_chain::test_chain_child_replaced_with_chain_first PASSED
t/integration/test_canvas.py::test_chain::test_chain_child_replaced_with_chain_middle FAILED
============================================================================================ FAILURES =============================================================================================
_____________________________________________________________________ test_chain.test_chain_child_replaced_with_chain_middle ______________________________________________________________________
self = <t.integration.test_canvas.test_chain object at 0x105e79310>, manager = <celery.contrib.testing.manager.Manager object at 0x119174260>
def test_chain_child_replaced_with_chain_middle(self, manager):
orig_sig = chain(
identity.s(42), replace_with_chain.s(), identity.s()
)
res_obj = orig_sig.delay()
> assert res_obj.get(timeout=TIMEOUT) == 42
t/integration/test_canvas.py:803:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
celery/result.py:251: in get
return self.backend.wait_for_pending(
celery/backends/asynchronous.py:221: in wait_for_pending
for _ in self._wait_for_pending(result, **kwargs):
celery/backends/asynchronous.py:287: in _wait_for_pending
for _ in self.drain_events_until(
celery/backends/asynchronous.py:54: in drain_events_until
yield self.wait_for(p, wait, timeout=interval)
celery/backends/asynchronous.py:63: in wait_for
wait(timeout=timeout)
celery/backends/redis.py:161: in drain_events
message = self._pubsub.get_message(timeout=timeout)
.tox/3.12-integration-rabbitmq_valkey/lib/python3.12/site-packages/valkey/client.py:1072: in get_message
response = self.parse_response(block=(timeout is None), timeout=timeout)
.tox/3.12-integration-rabbitmq_valkey/lib/python3.12/site-packages/valkey/client.py:883: in parse_response
response = self._execute(conn, try_read)
.tox/3.12-integration-rabbitmq_valkey/lib/python3.12/site-packages/valkey/client.py:859: in _execute
return conn.retry.call_with_retry(
.tox/3.12-integration-rabbitmq_valkey/lib/python3.12/site-packages/valkey/retry.py:62: in call_with_retry
return do()
.tox/3.12-integration-rabbitmq_valkey/lib/python3.12/site-packages/valkey/client.py:860: in <lambda>
lambda: command(*args, **kwargs),
.tox/3.12-integration-rabbitmq_valkey/lib/python3.12/site-packages/valkey/client.py:881: in try_read
return conn.read_response(disconnect_on_error=False, push_request=True)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <valkey.connection.Connection(host=localhost,port=6380,db=0)>, disable_decoding = False
def read_response(
self,
disable_decoding=False,
*,
disconnect_on_error=True,
push_request=False,
):
"""Read the response from a previously sent command"""
host_error = self._host_error()
try:
if self.protocol in ["3", 3] and not LIBVALKEY_AVAILABLE:
response = self._parser.read_response(
disable_decoding=disable_decoding, push_request=push_request
)
else:
response = self._parser.read_response(disable_decoding=disable_decoding)
except socket.timeout:
if disconnect_on_error:
self.disconnect()
raise TimeoutError(f"Timeout reading from {host_error}")
except OSError as e:
if disconnect_on_error:
self.disconnect()
raise ConnectionError(
f"Error while reading from {host_error}" f" : {e.args}"
)
except BaseException:
# Also by default close in case of BaseException. A lot of code
# relies on this behaviour when doing Command/Response pairs.
# See #1128.
if disconnect_on_error:
self.disconnect()
raise
if self.health_check_interval:
self.next_health_check = time() + self.health_check_interval
if isinstance(response, ResponseError):
try:
> raise response
E valkey.exceptions.ResponseError: NOSUB 'unsubscribe' command executed not in subscribed mode
.tox/3.12-integration-rabbitmq_valkey/lib/python3.12/site-packages/valkey/connection.py:570: ResponseError
---------------------------------------------------------------------------------------- Captured log call ----------------------------------------------------------------------------------------
INFO celery.worker.strategy:strategy.py:161 Task t.integration.tasks.identity[90ef0c6e-095a-446b-92ae-d4b5c6007f66] received
INFO celery.worker.strategy:strategy.py:161 Task t.integration.tasks.replace_with_chain[e7e908fe-71fa-45a0-9a1e-0d97334778bf] received
INFO celery.app.trace:trace.py:128 Task t.integration.tasks.identity[90ef0c6e-095a-446b-92ae-d4b5c6007f66] succeeded in 0.001407832998665981s: 42
INFO celery.worker.strategy:strategy.py:161 Task t.integration.tasks.identity[b727619c-72be-4079-b003-87b4d025d181] received
======================================================================================== warnings summary =========================================================================================
t/integration/test_canvas.py::test_chain::test_chain_error_handler_with_eta
/Users/nusnus/dev/GitHub/celery/celery/canvas.py:2301: CPendingDeprecationWarning: task_allow_error_cb_on_chord_header=False is pending deprecation in a future release of Celery.
Please test the new behavior by setting task_allow_error_cb_on_chord_header to True and report any concerns you might have in our issue tracker before we make a final decision regarding how errbacks should behave when used with chords.
warnings.warn(
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
===================================================================================== short test summary info =====================================================================================
FAILED t/integration/test_canvas.py::test_chain::test_chain_child_replaced_with_chain_middle - valkey.exceptions.ResponseError: NOSUB 'unsubscribe' command executed not in subscribed mode
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
====================================================== 1 failed, 27 passed, 17 skipped, 2 xfailed, 1 xpassed, 1 warning in 84.34s (0:01:24) =======================================================
Exception ignored in: <function AsyncResult.__del__ at 0x1051c3f60>
Traceback (most recent call last):
File "/Users/nusnus/dev/GitHub/celery/celery/result.py", line 417, in __del__
File "/Users/nusnus/dev/GitHub/celery/celery/backends/asynchronous.py", line 208, in remove_pending_result
File "/Users/nusnus/dev/GitHub/celery/celery/backends/asynchronous.py", line 216, in on_result_fulfilled
File "/Users/nusnus/dev/GitHub/celery/celery/backends/redis.py", line 184, in cancel_for
File "/Users/nusnus/dev/GitHub/celery/.tox/3.12-integration-rabbitmq_valkey/lib/python3.12/site-packages/valkey/client.py", line 1000, in unsubscribe
File "/Users/nusnus/dev/GitHub/celery/.tox/3.12-integration-rabbitmq_valkey/lib/python3.12/site-packages/valkey/client.py", line 804, in execute_command
File "/Users/nusnus/dev/GitHub/celery/.tox/3.12-integration-rabbitmq_valkey/lib/python3.12/site-packages/valkey/connection.py", line 1107, in get_connection
File "/Users/nusnus/dev/GitHub/celery/.tox/3.12-integration-rabbitmq_valkey/lib/python3.12/site-packages/valkey/connection.py", line 314, in connect
File "/Users/nusnus/dev/GitHub/celery/.tox/3.12-integration-rabbitmq_valkey/lib/python3.12/site-packages/valkey/connection.py", line 345, in on_connect
File "/Users/nusnus/dev/GitHub/celery/.tox/3.12-integration-rabbitmq_valkey/lib/python3.12/site-packages/valkey/_parsers/libvalkey.py", line 51, in on_connect
ImportError: sys.meta_path is None, Python is likely shutting down
Exception ignored in: <function AsyncResult.__del__ at 0x1051c3f60>
Traceback (most recent call last):
File "/Users/nusnus/dev/GitHub/celery/celery/result.py", line 417, in __del__
File "/Users/nusnus/dev/GitHub/celery/celery/backends/asynchronous.py", line 208, in remove_pending_result
File "/Users/nusnus/dev/GitHub/celery/celery/backends/asynchronous.py", line 216, in on_result_fulfilled
File "/Users/nusnus/dev/GitHub/celery/celery/backends/redis.py", line 184, in cancel_for
File "/Users/nusnus/dev/GitHub/celery/.tox/3.12-integration-rabbitmq_valkey/lib/python3.12/site-packages/valkey/client.py", line 1000, in unsubscribe
File "/Users/nusnus/dev/GitHub/celery/.tox/3.12-integration-rabbitmq_valkey/lib/python3.12/site-packages/valkey/client.py", line 804, in execute_command
File "/Users/nusnus/dev/GitHub/celery/.tox/3.12-integration-rabbitmq_valkey/lib/python3.12/site-packages/valkey/connection.py", line 1120, in get_connection
File "/Users/nusnus/dev/GitHub/celery/.tox/3.12-integration-rabbitmq_valkey/lib/python3.12/site-packages/valkey/connection.py", line 314, in connect
File "/Users/nusnus/dev/GitHub/celery/.tox/3.12-integration-rabbitmq_valkey/lib/python3.12/site-packages/valkey/connection.py", line 345, in on_connect
File "/Users/nusnus/dev/GitHub/celery/.tox/3.12-integration-rabbitmq_valkey/lib/python3.12/site-packages/valkey/_parsers/libvalkey.py", line 51, in on_connect
ImportError: sys.meta_path is None, Python is likely shutting down
Exception ignored in: <function AsyncResult.__del__ at 0x1051c3f60>
Traceback (most recent call last):
File "/Users/nusnus/dev/GitHub/celery/celery/result.py", line 417, in __del__
File "/Users/nusnus/dev/GitHub/celery/celery/backends/asynchronous.py", line 208, in remove_pending_result
File "/Users/nusnus/dev/GitHub/celery/celery/backends/asynchronous.py", line 216, in on_result_fulfilled
File "/Users/nusnus/dev/GitHub/celery/celery/backends/redis.py", line 184, in cancel_for
File "/Users/nusnus/dev/GitHub/celery/.tox/3.12-integration-rabbitmq_valkey/lib/python3.12/site-packages/valkey/client.py", line 1000, in unsubscribe
File "/Users/nusnus/dev/GitHub/celery/.tox/3.12-integration-rabbitmq_valkey/lib/python3.12/site-packages/valkey/client.py", line 804, in execute_command
File "/Users/nusnus/dev/GitHub/celery/.tox/3.12-integration-rabbitmq_valkey/lib/python3.12/site-packages/valkey/connection.py", line 1120, in get_connection
File "/Users/nusnus/dev/GitHub/celery/.tox/3.12-integration-rabbitmq_valkey/lib/python3.12/site-packages/valkey/connection.py", line 314, in connect
File "/Users/nusnus/dev/GitHub/celery/.tox/3.12-integration-rabbitmq_valkey/lib/python3.12/site-packages/valkey/connection.py", line 345, in on_connect
File "/Users/nusnus/dev/GitHub/celery/.tox/3.12-integration-rabbitmq_valkey/lib/python3.12/site-packages/valkey/_parsers/libvalkey.py", line 51, in on_connect
ImportError: sys.meta_path is None, Python is likely shutting down
3.12-integration-rabbitmq_valkey: exit 1 (85.30 seconds) /Users/nusnus/dev/GitHub/celery> pytest -xsvv t/integration pid=74706
3.12-integration-rabbitmq_valkey: FAIL code 1 (87.03=setup[1.73]+cmd[85.30] seconds)
evaluation failed :( (87.41 seconds) |
|
hi @Nusnus so weird thing happened, i got the same error, then added a |
Tbh I'm not sure, but it does reproduce in the CI so that's a blocker my friend. I suggest good old debugging to find why it happens 🙏 |
|
i might have miscommunicated to inform you on the issue tho: and i'm not sure the traceback is accurate, since putting and the error message seems weird as well, i do not see anywhere in the traceback |
|
Hi, I don't know if this is the right place to write this, but I had the same problem with valkey 8.0.1: |
hi |
|
hi @Nusnus i'll make an issue in valkey's github inforimng the problem with 8.0.X |
Nusnus
left a comment
There was a problem hiding this comment.
Can you please rebase on main / merge main and fix the conflicts so we can see how does the CI reacts?
|
i started an issue in valkey's github the current guess is that there's some race condition happening in celery tests with valkey8 |
Awesome, thank you! |
|
when not using tox, the above error doesn't happen anymore note that the above command will raise some errors due to lack of configuration, but the error in discussion doesn't happen let me know what you think |
|
@amirreza8002 I got the error in my code, maybe a test that raises an error which can happen in actual code is better than a test which passes 😅 |
|
hi @zukka77 that's because it's misconfigured I'm not trying to hide any bugs here 🙃 and now I'm trying to find what is causing the race condition. my current guess is that tox is causing it, because the previous problem doesn't happen when running tests without tox. if you have a reason to disagree please do share your thoughts |
|
ok i feel like tihs is losing clarity
this means two things:
sorry it got long |
|
Hi @amirreza8002 to clarify I'm here because I had the same error on a little project I'm doing (where I use valkey as a drop-in replacement of redis, my celery instance is configured as if I'm using redis) , I've never run the tests by myself. As I am understanding :
I'm sorry if I caused confusion :( |
|
hi so if i'm to understand correctly, you are getting the error in your project, and not in celery tests? if so, can you provide information so i can reproduce it and see? |
|
@amirreza8002 i created this repo https://git.zukka.net/andrea/valkey-celery-test with a fake backend which reproduces the error. This happens when i call a .get() on a "result" after a .wait() on another tasks which has no return value: res=app.send_task("task1") //task with no return value
res.wait()
res=app.send_task("task2")
res.get() // <-- here I get the error with valkey 8 |
Signed-off-by: amirreza <[email protected]>
Signed-off-by: amirreza <[email protected]>
|
hi @Nusnus |
auvipy
left a comment
There was a problem hiding this comment.
I will come back to this after celery v5.5 stable is released
|
reminder that this exists :p |
|
I think we do not need it as it is just a drop in replacement for redis and redis is open source again. And we can already see a 3rd party library for this. |
|
Posted my argument why it can be interested to integrate into a celery - #9092 (comment) |
|
from what i can gather, the redis backend probably will work with valkey as well but: it also makes it easier to use valkey specific packages, such as libvalkey, or to switch the clinet to valkey-glide (when they make their sync interface) it also makes more sense to have a valkey version to people who are already using valkey-py in their projects and installing redis-py would be a waste but you are the maintainers of celery and if you feel it's unnecessary, I'm fine to close the pr |
|
I think this can easily live as an extension of celery for now |
|
Important notes about the limitations (and risks) of Redis' adoption of AGPL from: https://www.thestack.technology/redis-reverts-to-open-source. I think Celery support for Valkey would be helpful.
|
|
I think we can use the same codebase for supporting redis, valkey and dragonflydb.... that would reduce code duplication |
|
hi @auvipy |
|
If your concerned about code resuse maybe just alias vallkey to the redis backend and add code into it ro look for native valkey libraries before falling back to redis at least for the time being since they are for Celery's use case the same. |
no it is still a lot of code and 2 separate codebase for same back end with different name. we should go for alias approach now with minimal code changes here. And here is a relevant PR that should do the trick! celery/kombu#2246 |
|
IMO, it seems like this PR #9300 is doing it in a reasonable OOP way. The situation seems to be there is a lot of commonality between 2 classes. Ok, so we move the common code into a parent class, |
|
From what I can gather, the alias approach, e.g., for pyamqp vs amqp vs librabbitmq, seems to be more about providing fail-over type of functionality. I.e., celery/kombu#189 (comment) |
|
I saw that this PR is still in "draft". Does anyone still actively working on it? |
Kombu PR does provide a working alias for the broker, and even recently released Valkey 9.0 should fully work with that (they should be fully compatible still, while they do provide unique features now that Redis does not). Kombu does not play a role for the results backend though, for that we need separate support in Celery, but only in case we can't use Redis. edit: I've implemented a small POC that installs combination of this PR and Kombu PR (bit tricky, their deps conflict) and configures celery to use |
|
Over time, the differences between Redis and Valkey are likely to become more significant. It is recommended to use valkey-py instead of redis-py for Valkey adaptation. |
There was a problem hiding this comment.
Pull request overview
This PR adds a Valkey result backend to Celery and refactors the existing Redis backend to share implementation via a new BaseKeyValueBackend abstraction.
Changes:
- Introduces
celery.backends.valkeyand registers new backend URL aliases (valkey://,valkeys://,valkeysentinel://). - Refactors Redis backend/sentinel backend to inherit from
BaseKeyValueBackend/BaseSentinelBackend. - Adds CI/tox integration coverage for Valkey plus new unit tests and documentation updates.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
celery/backends/base_keyval.py |
New shared Redis/Valkey key-value backend implementation (incl. chords, SSL params, sentinel helpers). |
celery/backends/redis.py |
Refactored to thin wrapper around BaseKeyValueBackend / BaseSentinelBackend. |
celery/backends/valkey.py |
New Valkey result backend + sentinel backend. |
celery/app/backends.py |
Registers Valkey backend aliases. |
celery/app/defaults.py |
Adds valkey_* configuration namespace. |
t/unit/backends/test_valkey.py |
Adds unit test suite for Valkey backend and consumer. |
t/unit/backends/test_redis.py |
Updates Redis unit tests to match refactor paths/attributes. |
t/integration/test_canvas.py |
Marks known chord error propagation issue as xfail for Valkey backend too. |
tox.ini |
Adds rabbitmq_valkey integration environment. |
.github/workflows/python-package.yml |
Adds Valkey service and toxenv to integration matrix. |
requirements/extras/valkey.txt |
New Valkey extra requirements file. |
requirements/test-integration.txt / requirements/test-ci-base.txt |
Includes Valkey extra in test requirements. |
setup.py |
Adds valkey to extras list. |
docs/includes/installation.txt |
Documents celery[valkey] bundle. |
docs/getting-started/backends-and-brokers/valkey.rst |
New Valkey documentation page (currently broker-focused). |
docs/getting-started/backends-and-brokers/index.rst |
Adds Valkey to toctree and overview content. |
README.rst |
Mentions Valkey in supported transports/backends and adds reference link. |
| return [ | ||
| e[1] for e in self._get_sorted_set(key) | ||
| if (min_ == "-inf" or e[0] >= min_) and | ||
| (max_ == "+inf" or e[1] <= max_) |
There was a problem hiding this comment.
The Valkey mock client’s zrangebyscore() compares max_ to e[1] (the value) instead of e[0] (the score). This makes the fake implementation incorrect and can cause future tests using numeric score bounds to fail or behave incorrectly.
| (max_ == "+inf" or e[1] <= max_) | |
| (max_ == "+inf" or e[0] <= max_) |
| - **Message Transports** | ||
|
|
||
| - RabbitMQ_, Redis_, Amazon SQS, Google Pub/Sub | ||
| - RabbitMQ_, Redis_, Amazon SQS, Google Pub/Sub, Valkey_ |
There was a problem hiding this comment.
This adds Valkey to the list of supported “Message Transports”, but this PR appears to only implement a result backend (no broker transport registration in this repo). Please avoid claiming broker support in the README until transport support is actually implemented (or clarify what works).
| - RabbitMQ_, Redis_, Amazon SQS, Google Pub/Sub, Valkey_ | |
| - RabbitMQ_, Redis_, Amazon SQS, Google Pub/Sub |
| rabbitmq_redis: TEST_BROKER=pyamqp:// | ||
| rabbitmq_redis: TEST_BACKEND=redis:// | ||
|
|
||
| rabbitmq_valkey: TEST_BROKER=amqp:// |
There was a problem hiding this comment.
rabbitmq_valkey uses TEST_BROKER=amqp:// while the other RabbitMQ integration environments use pyamqp://. Using amqp:// can change which transport gets selected (depending on installed extras) and make the integration matrix less consistent/reproducible; consider using pyamqp:// here as well.
| rabbitmq_valkey: TEST_BROKER=amqp:// | |
| rabbitmq_valkey: TEST_BROKER=pyamqp:// |
| # If connparams or query string contain ssl params, raise error | ||
| if (any(key in connparams for key in ssl_param_keys) or | ||
| any(key in query for key in ssl_param_keys)): | ||
| raise ValueError(self.SSL_PARAMS_AND_SCHEME_MISMATCH) |
There was a problem hiding this comment.
_params_from_url() raises ValueError(self.SSL_PARAMS_AND_SCHEME_MISMATCH), but SSL_PARAMS_AND_SCHEME_MISMATCH is not defined on the class. This will raise AttributeError when a non-TLS URL includes SSL query parameters. Use the module constant (e.g. E_SSL_PARAMS_AND_SCHEME_MISMATCH.format(self.backend_name) or similar) or define a class attribute.
| raise ValueError(self.SSL_PARAMS_AND_SCHEME_MISMATCH) | |
| raise ValueError(getattr( | |
| self, 'SSL_PARAMS_AND_SCHEME_MISMATCH', | |
| 'SSL connection parameters may only be used with the ' | |
| f'{self.backend_name}s:// scheme' | |
| )) |
| E_MISSING = """ | ||
| You need to install the {} library in order to use \ | ||
| the Valkey result store backend. | ||
| """ | ||
|
|
||
| E_SENTINEL_MISSING = """ | ||
| You need to install the {} library with support of \ | ||
| sentinel in order to use the Valkey result store backend. | ||
| """ | ||
|
|
||
| W_SSL_CERT_OPTIONAL = """ | ||
| Setting ssl_cert_reqs=CERT_OPTIONAL when connecting to {} means that \ | ||
| celery might not validate the identity of the valkey broker when connecting. \ | ||
| This leaves you vulnerable to man in the middle attacks. | ||
| """ | ||
|
|
||
| W_SSL_CERT_NONE = """ | ||
| Setting ssl_cert_reqs=CERT_NONE when connecting to {0} means that celery \ | ||
| will not validate the identity of the {0} broker when connecting. This \ | ||
| leaves you vulnerable to man in the middle attacks. | ||
| """ | ||
|
|
||
| E_SSL_PARAMS_AND_SCHEME_MISMATCH = """ | ||
| SSL connection parameters have been provided but the specified URL scheme \ | ||
| is {0}://. A Valkey SSL connection URL should use the scheme {0}s://. | ||
| """ |
There was a problem hiding this comment.
The shared error/warning message templates are hard-coded to “Valkey” / “valkey broker” even when used by RedisBackend, leading to misleading exceptions/logs (e.g., missing redis dependency would say “Valkey result store backend”). These strings should be backend-neutral and interpolate the backend name consistently.
| self.connparams['connection_class'] = self.connection_class_ssl | ||
|
|
||
| if url: | ||
| self.connparams = self._params_from_url(url, self.connparams) | ||
|
|
||
| if ('connection_class' in self.connparams and | ||
| issubclass(self.connparams['connection_class'], self.backend_module.SSLConnection)): |
There was a problem hiding this comment.
connection_class_ssl is evaluated in the base class using backend_module/backend before subclasses override them, so it stays None for RedisBackend/ValkeyBackend. When *_backend_use_ssl is configured, connparams['connection_class'] becomes None and the subsequent issubclass(...) check can raise TypeError, and TLS connections via config dict won’t work. Define connection_class_ssl in each concrete backend (e.g., redis.SSLConnection / valkey.SSLConnection) and guard the issubclass check by ensuring connection_class is a class.
| self.connparams['connection_class'] = self.connection_class_ssl | |
| if url: | |
| self.connparams = self._params_from_url(url, self.connparams) | |
| if ('connection_class' in self.connparams and | |
| issubclass(self.connparams['connection_class'], self.backend_module.SSLConnection)): | |
| connection_class_ssl = getattr( | |
| self.backend_module, 'SSLConnection', self.connection_class_ssl, | |
| ) | |
| if isinstance(connection_class_ssl, type): | |
| self.connparams['connection_class'] = connection_class_ssl | |
| if url: | |
| self.connparams = self._params_from_url(url, self.connparams) | |
| connection_class = self.connparams.get('connection_class') | |
| if (isinstance(connection_class, type) and | |
| issubclass(connection_class, self.backend_module.SSLConnection)): |
| from celery.exceptions import BackendStoreError, ChordError, ImproperlyConfigured | ||
| from celery.result import GroupResult, allow_join_result | ||
| from celery.utils.functional import _regen, dictfilter | ||
| from celery.utils.log import get_logger |
There was a problem hiding this comment.
get_logger is imported but never used in this module after the refactor, which will fail linting (unused import). Remove it or use it to define a logger.
| from celery.utils.log import get_logger |
| @@ -45,8 +46,6 @@ individual transport (see :ref:`broker_toc`). | |||
| +---------------+--------------+----------------+--------------------+ | |||
| | *Kafka* | Experimental | No | No | | |||
| +---------------+--------------+----------------+--------------------+ | |||
There was a problem hiding this comment.
The broker comparison table no longer includes the GC PubSub row even though gcpubsub is still listed in the toctree and has a summary section below. This makes the “Broker Overview” table inconsistent; either restore the row or remove the related content.
| +---------------+--------------+----------------+--------------------+ | |
| +---------------+--------------+----------------+--------------------+ | |
| | *GC PubSub* | Experimental | No | No | | |
| +---------------+--------------+----------------+--------------------+ |
| Valkey is a free licenced fork of Redis, with a similar API that almost works the same. | ||
| it does everything redis does | ||
|
|
||
| :red:`See documentation for details <broker-valkey>` |
There was a problem hiding this comment.
The Valkey section has multiple documentation issues: spelling/grammar (“free licenced”, sentence casing), and :red: is not a valid Sphinx role here (likely meant :ref:). As-is this is likely to break the docs build and should be corrected.
| Valkey is a free licenced fork of Redis, with a similar API that almost works the same. | |
| it does everything redis does | |
| :red:`See documentation for details <broker-valkey>` | |
| Valkey is a freely licensed fork of Redis with a similar API. | |
| It does everything Redis does. | |
| :ref:`See documentation for details <broker-valkey>` |
| Configuration is easy, just configure the location of | ||
| your Valkey database: | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| app.conf.broker_url = 'valkey://localhost:6379/0' | ||
|
|
||
| Where the URL is in the format of: |
There was a problem hiding this comment.
The documentation uses broker_url = 'valkey://…' / valkeysentinel://… examples, but this PR only adds a result backend implementation and does not add/register a Kombu transport for Valkey. As written, these broker examples are likely non-functional; either implement the broker transport support or scope this page to the result backend (and mention that Valkey can be used with the existing Redis transport by pointing redis:// at a Valkey server, if that’s the intended story).
There was a problem hiding this comment.
These issues Copilot found all seem fixable. Is the next step to have Copilot work through these issues it found?
Description
add support for valkey as a backend.
it includes tests and documentation.
the coverage is 96%
Fixes #9092