mirror of https://github.com/apache/superset.git
chore: use json codec for key value lock (#29285)
This commit is contained in:
parent
796726376a
commit
9f70697046
|
@ -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,
|
||||
|
|
|
@ -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),
|
||||
|
|
Loading…
Reference in New Issue