Skip to content

Commit 59bc5c7

Browse files
committed
feat: updated source file loader
1 parent 0279e99 commit 59bc5c7

5 files changed

Lines changed: 377 additions & 354 deletions

File tree

examples/basic.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ async def samples_queue_info(self, task_queues: TaskQueues) -> QueueInfo:
2626
config=SAQConfig(
2727
redis_url="redis://localhost:6397/0",
2828
web_enabled=True,
29+
use_server_lifespan=True,
2930
queue_configs=[
3031
QueueConfig(
3132
name="samples",

litestar_saq/_util.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
from __future__ import annotations
22

3-
import importlib
3+
import importlib.util
44
import sys
55
from functools import lru_cache
66
from importlib import import_module
7-
from importlib.machinery import SourceFileLoader
87
from pathlib import Path
98
from typing import TYPE_CHECKING, Any
109

@@ -25,10 +24,10 @@ def module_to_os_path(dotted_path: str) -> Path:
2524
Ensures that pkgutil returns a valid source file loader.
2625
"""
2726
src = importlib.util.find_spec(dotted_path)
28-
if not isinstance(src, SourceFileLoader):
27+
if src is None:
2928
msg = f"Couldn't find the path for {dotted_path}"
3029
raise TypeError(msg)
31-
return Path(str(src.path).removesuffix("/__init__.py")) # type: ignore[unreachable]
30+
return Path(str(src.origin).removesuffix("/__init__.py")) # type: ignore[unreachable]
3231

3332

3433
def import_string(dotted_path: str) -> Any:

litestar_saq/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def serializer(value: Any) -> str:
4040

4141

4242
def _get_static_files() -> Path:
43-
return Path(module_to_os_path("saq.web") / "static")
43+
return Path(module_to_os_path("saq") / "web" / "static")
4444

4545

4646
@dataclass

0 commit comments

Comments
 (0)