Skip to content

Commit e8918bd

Browse files
committed
a few more ig
1 parent 85c00e7 commit e8918bd

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

reflex/utils/prerequisites.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717

1818
from alembic.util.exc import CommandError
1919
from packaging import version
20-
from redis import Redis as RedisSync
21-
from redis.asyncio import Redis
22-
from redis.exceptions import RedisError
2320

2421
from reflex import constants, model
2522
from reflex.config import Config, get_config
@@ -29,6 +26,9 @@
2926
from reflex.utils.misc import get_module_path
3027

3128
if typing.TYPE_CHECKING:
29+
from redis import Redis as RedisSync
30+
from redis.asyncio import Redis
31+
3232
from reflex.app import App
3333

3434

@@ -370,6 +370,8 @@ def get_redis() -> Redis | None:
370370
Returns:
371371
The asynchronous redis client.
372372
"""
373+
from redis.asyncio import Redis
374+
from redis.exceptions import RedisError
373375
if (redis_url := parse_redis_url()) is not None:
374376
return Redis.from_url(
375377
redis_url,
@@ -384,6 +386,8 @@ def get_redis_sync() -> RedisSync | None:
384386
Returns:
385387
The synchronous redis client.
386388
"""
389+
from redis import Redis as RedisSync
390+
from redis.exceptions import RedisError
387391
if (redis_url := parse_redis_url()) is not None:
388392
return RedisSync.from_url(
389393
redis_url,
@@ -418,6 +422,7 @@ async def get_redis_status() -> dict[str, bool | None]:
418422
Returns:
419423
The status of the Redis connection.
420424
"""
425+
from redis.exceptions import RedisError
421426
try:
422427
status = True
423428
redis_client = get_redis()

reflex/utils/processes.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from typing import Any, Literal, overload
1717

1818
import rich.markup
19-
from redis.exceptions import RedisError
2019
from rich.progress import Progress
2120

2221
from reflex import constants
@@ -45,6 +44,9 @@ def get_num_workers() -> int:
4544
"""
4645
if (redis_client := prerequisites.get_redis_sync()) is None:
4746
return 1
47+
48+
from redis.exceptions import RedisError
49+
4850
try:
4951
redis_client.ping()
5052
except RedisError as re:

0 commit comments

Comments
 (0)