Skip to content

Commit 7f62adb

Browse files
committed
clean up
1 parent 7bb6ed4 commit 7f62adb

File tree

1 file changed

+3
-4
lines changed
  • src/integrations/prefect-redis/prefect_redis

1 file changed

+3
-4
lines changed

src/integrations/prefect-redis/prefect_redis/locking.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ def __setstate__(self, state: dict[str, Any]) -> None:
8383

8484
# ------------------------------------
8585

86-
# internal
8786
def _ensure_clients(self) -> None:
8887
if self.client is None:
8988
self.client = Redis(
@@ -144,15 +143,14 @@ async def aacquire_lock(
144143
lock_name = self._lock_name_for_key(key)
145144
lock = self._locks.get(lock_name)
146145

147-
if lock is not None and isinstance(
148-
lock, AsyncLock
149-
): # Still need to check if it *is* an AsyncLock to call await .owned()
146+
if lock is not None and isinstance(lock, AsyncLock):
150147
if await lock.owned() and lock.local.token == holder.encode():
151148
return True
152149
else:
153150
lock = None
154151

155152
if lock is None:
153+
assert self.async_client is not None, "Async client should be initialized"
156154
new_lock = AsyncLock(
157155
self.async_client, lock_name, timeout=hold_timeout, thread_local=False
158156
)
@@ -219,6 +217,7 @@ def wait_for_lock(self, key: str, timeout: Optional[float] = None) -> bool:
219217
async def await_for_lock(self, key: str, timeout: Optional[float] = None) -> bool:
220218
self._ensure_clients()
221219
lock_name = self._lock_name_for_key(key)
220+
assert self.async_client is not None, "Async client should be initialized"
222221
lock = AsyncLock(
223222
self.async_client, lock_name
224223
) # Create a temporary lock for waiting

0 commit comments

Comments
 (0)