redis: include local property on Lock class (#6083)

The Lock class as a property local that has a token property that sometimes
needs be accessed / set.

```python
lock = redis.lock(key)
lock.local.token = token
lock.extend(10)
```

Technically the type of `local` is `SimpleNamespace | threading.local`
but I think this setup is a bit stricter but satisfies the API.
This commit is contained in:
Steve Dignam
2021-09-29 00:16:23 -04:00
committed by GitHub
parent 4ac969ad2c
commit 4ef07810c4

View File

@@ -1,11 +1,16 @@
from types import TracebackType
from typing import Any, Text, Type, Union
from typing_extensions import Protocol
from redis.client import Redis
_TokenValue = Union[bytes, Text]
class _Local(Protocol):
token: _TokenValue | None
class Lock:
local: _Local
def __init__(
self,
redis: Redis[Any],