Skip to content

Feature/fix bug when check redis #6860

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/backend/base/langflow/services/cache/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,16 +219,15 @@
self.expiration_time = expiration_time

# check connection
def is_connected(self) -> bool:
"""Check if the Redis client is connected."""
# change to keep async safe
async def is_connected(self) -> bool:
import redis

try:
asyncio.run(self._client.ping())
except redis.exceptions.ConnectionError:
logger.exception("RedisCache could not connect to the Redis server")
await self._client.ping() # 直接使用await
return True

Check failure on line 228 in src/backend/base/langflow/services/cache/service.py

View workflow job for this annotation

GitHub Actions / Ruff Style Check (3.13)

Ruff (TRY300)

src/backend/base/langflow/services/cache/service.py:228:13: TRY300 Consider moving this statement to an `else` block

Check failure on line 228 in src/backend/base/langflow/services/cache/service.py

View workflow job for this annotation

GitHub Actions / Ruff Style Check (3.13)

Ruff (TRY300)

src/backend/base/langflow/services/cache/service.py:228:13: TRY300 Consider moving this statement to an `else` block
except (redis.ConnectionError, redis.TimeoutError):
return False
return True

@override
async def get(self, key, lock=None):
Expand Down
Loading