refactor: Move imports to avoid circular dependencies in socket and VLCPlayerService
This commit is contained in:
@@ -5,8 +5,6 @@ import logging
|
|||||||
import socketio
|
import socketio
|
||||||
|
|
||||||
from app.core.config import settings
|
from app.core.config import settings
|
||||||
from app.core.database import get_session_factory
|
|
||||||
from app.services.vlc_player import get_vlc_player_service
|
|
||||||
from app.utils.auth import JWTUtils
|
from app.utils.auth import JWTUtils
|
||||||
from app.utils.cookies import extract_access_token_from_cookies
|
from app.utils.cookies import extract_access_token_from_cookies
|
||||||
|
|
||||||
@@ -123,6 +121,10 @@ class SocketManager:
|
|||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
# Import here to avoid circular imports
|
||||||
|
from app.core.database import get_session_factory # noqa: PLC0415
|
||||||
|
from app.services.vlc_player import get_vlc_player_service # noqa: PLC0415
|
||||||
|
|
||||||
# Get VLC player service with database factory
|
# Get VLC player service with database factory
|
||||||
vlc_player = get_vlc_player_service(get_session_factory())
|
vlc_player = get_vlc_player_service(get_session_factory())
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ from collections.abc import Callable
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from fastapi import HTTPException, status
|
|
||||||
from sqlmodel.ext.asyncio.session import AsyncSession
|
from sqlmodel.ext.asyncio.session import AsyncSession
|
||||||
|
|
||||||
from app.core.logging import get_logger
|
from app.core.logging import get_logger
|
||||||
@@ -15,7 +14,6 @@ from app.models.sound import Sound
|
|||||||
from app.models.sound_played import SoundPlayed
|
from app.models.sound_played import SoundPlayed
|
||||||
from app.repositories.sound import SoundRepository
|
from app.repositories.sound import SoundRepository
|
||||||
from app.repositories.user import UserRepository
|
from app.repositories.user import UserRepository
|
||||||
from app.services.credit import CreditService, InsufficientCreditsError
|
|
||||||
from app.services.socket import socket_manager
|
from app.services.socket import socket_manager
|
||||||
from app.utils.audio import get_sound_file_path
|
from app.utils.audio import get_sound_file_path
|
||||||
|
|
||||||
@@ -332,6 +330,9 @@ class VLCPlayerService:
|
|||||||
insufficient credits, VLC failure)
|
insufficient credits, VLC failure)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from fastapi import HTTPException, status # noqa: PLC0415, I001
|
||||||
|
from app.services.credit import CreditService, InsufficientCreditsError # noqa: PLC0415
|
||||||
|
|
||||||
if not self.db_session_factory:
|
if not self.db_session_factory:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||||
|
|||||||
Reference in New Issue
Block a user