This is an automated email from the ASF dual-hosted git repository.

villebro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 9f70697046 chore: use json codec for key value lock (#29285)
9f70697046 is described below

commit 9f70697046599dadac75713fea0f1e586512c6bb
Author: Ville Brofeldt <[email protected]>
AuthorDate: Wed Jun 19 01:33:47 2024 +0300

    chore: use json codec for key value lock (#29285)
---
 superset/utils/lock.py               | 4 ++--
 tests/unit_tests/utils/lock_tests.py | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/superset/utils/lock.py b/superset/utils/lock.py
index 50bfb6d955..d3c55d459c 100644
--- a/superset/utils/lock.py
+++ b/superset/utils/lock.py
@@ -26,7 +26,7 @@ from typing import Any, cast, TypeVar, Union
 
 from superset.exceptions import CreateKeyValueDistributedLockFailedException
 from superset.key_value.exceptions import KeyValueCreateFailedError
-from superset.key_value.types import KeyValueResource, PickleKeyValueCodec
+from superset.key_value.types import JsonKeyValueCodec, KeyValueResource
 from superset.utils import json
 
 LOCK_EXPIRATION = timedelta(seconds=30)
@@ -83,7 +83,7 @@ def KeyValueDistributedLock(  # pylint: disable=invalid-name
         DeleteExpiredKeyValueCommand(resource=KeyValueResource.LOCK).run()
         CreateKeyValueCommand(
             resource=KeyValueResource.LOCK,
-            codec=PickleKeyValueCodec(),
+            codec=JsonKeyValueCodec(),
             key=key,
             value=True,
             expires_on=datetime.now() + LOCK_EXPIRATION,
diff --git a/tests/unit_tests/utils/lock_tests.py 
b/tests/unit_tests/utils/lock_tests.py
index 270d082366..44eccebc30 100644
--- a/tests/unit_tests/utils/lock_tests.py
+++ b/tests/unit_tests/utils/lock_tests.py
@@ -42,7 +42,7 @@ def test_KeyValueDistributedLock_happy_path(mocker: 
MockerFixture) -> None:
     DeleteExpiredKeyValueCommand = mocker.patch(
         
"superset.commands.key_value.delete_expired.DeleteExpiredKeyValueCommand"
     )
-    PickleKeyValueCodec = 
mocker.patch("superset.utils.lock.PickleKeyValueCodec")
+    JsonKeyValueCodec = mocker.patch("superset.utils.lock.JsonKeyValueCodec")
 
     with freeze_time("2024-01-01"):
         with KeyValueDistributedLock("ns", a=1, b=2) as key:
@@ -51,7 +51,7 @@ def test_KeyValueDistributedLock_happy_path(mocker: 
MockerFixture) -> None:
             )
             CreateKeyValueCommand.assert_called_with(
                 resource=KeyValueResource.LOCK,
-                codec=PickleKeyValueCodec(),
+                codec=JsonKeyValueCodec(),
                 key=key,
                 value=True,
                 expires_on=datetime(2024, 1, 1, 0, 0, 30),

Reply via email to