Skip to content
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

Fix/scheduler conflict between routers #30

Merged
merged 2 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
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: 0 additions & 11 deletions routers/manage_accounts.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,22 @@
from typing import Dict, List

from apscheduler.schedulers.asyncio import AsyncIOScheduler
from fastapi import APIRouter, HTTPException
from hummingbot.client.settings import AllConnectorSettings
from starlette import status

from services.accounts_service import AccountsService
from utils.file_system import FileSystemUtil

# Initialize the scheduler
scheduler = AsyncIOScheduler()
router = APIRouter(tags=["Manage Credentials"])
file_system = FileSystemUtil(base_path="bots/credentials")
accounts_service = AccountsService()


@router.on_event("startup")
async def startup_event():
# Add the job to the scheduler
scheduler.start()
accounts_service.start_update_account_state_loop()


@router.on_event("shutdown")
async def shutdown_event():
# Shutdown the scheduler on application exit
scheduler.shutdown()


@router.get("/accounts-state", response_model=Dict[str, Dict[str, List[Dict]]])
async def get_all_accounts_state():
return accounts_service.get_accounts_state()
Expand Down
1 change: 0 additions & 1 deletion routers/manage_broker_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ def update_active_bots():
async def startup_event():
# Add the job to the scheduler
scheduler.add_job(update_active_bots, 'interval', seconds=10)
scheduler.start()


@router.on_event("shutdown")
Expand Down