fix in queue
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import threading
|
||||
import psutil
|
||||
from flask_socketio import emit
|
||||
from ..config import POLL_INTERVAL
|
||||
@@ -9,10 +10,10 @@ from .torrent_summary import cached_summary
|
||||
from . import rtorrent, smart_queue, traffic_history, automation_rules, torrent_stats
|
||||
|
||||
_started = False
|
||||
_start_lock = threading.Lock()
|
||||
|
||||
|
||||
def register_socketio_handlers(socketio):
|
||||
global _started
|
||||
|
||||
def poller():
|
||||
tick = 0
|
||||
@@ -63,12 +64,19 @@ def register_socketio_handlers(socketio):
|
||||
tick += 1
|
||||
socketio.sleep(POLL_INTERVAL)
|
||||
|
||||
def ensure_poller_started():
|
||||
global _started
|
||||
with _start_lock:
|
||||
if not _started:
|
||||
# Note: Poller startuje przy starcie aplikacji, więc Smart Queue i automatyzacje działają bez otwartego UI.
|
||||
socketio.start_background_task(poller)
|
||||
_started = True
|
||||
|
||||
ensure_poller_started()
|
||||
|
||||
@socketio.on("connect")
|
||||
def handle_connect():
|
||||
global _started
|
||||
if not _started:
|
||||
socketio.start_background_task(poller)
|
||||
_started = True
|
||||
ensure_poller_started()
|
||||
profile = active_profile()
|
||||
emit("connected", {"ok": True, "profile": profile})
|
||||
if not profile:
|
||||
|
||||
Reference in New Issue
Block a user