forked from kodorvan/stcs
Fixed
This commit is contained in:
@@ -9,6 +9,7 @@ logging.config.dictConfig(LOGGING_CONFIG)
|
||||
logger = logging.getLogger("bybit_ws")
|
||||
|
||||
event_loop = None # Сюда нужно будет установить event loop из основного приложения
|
||||
active_ws_tasks = {}
|
||||
|
||||
def get_or_create_event_loop() -> asyncio.AbstractEventLoop:
|
||||
"""
|
||||
@@ -31,11 +32,14 @@ async def run_ws_for_user(tg_id, message) -> None:
|
||||
"""
|
||||
Запускает WebSocket Bybit для пользователя с указанным tg_id.
|
||||
"""
|
||||
|
||||
api_key = await rq.get_bybit_api_key(tg_id)
|
||||
api_secret = await rq.get_bybit_secret_key(tg_id)
|
||||
|
||||
await start_execution_ws(api_key, api_secret, message)
|
||||
if tg_id not in active_ws_tasks or active_ws_tasks[tg_id].done():
|
||||
api_key = await rq.get_bybit_api_key(tg_id)
|
||||
api_secret = await rq.get_bybit_secret_key(tg_id)
|
||||
# Запускаем WebSocket как асинхронную задачу
|
||||
active_ws_tasks[tg_id] = asyncio.create_task(
|
||||
start_execution_ws(api_key, api_secret, message)
|
||||
)
|
||||
logger.info(f"WebSocket для пользователя {tg_id} запущен.")
|
||||
|
||||
|
||||
def on_order_callback(message, msg):
|
||||
|
Reference in New Issue
Block a user