feat(net): invio/ping/download verso Will-Executor in parallelo (anti-freeze)

Problema: i server Will-Executor venivano contattati in sequenza e, su
timeout, send_request riprovava 10x con sleep 3s (~130s per server morto).
Un solo server irraggiungibile bloccava l'intera operazione (impallamento UI).

Soluzione:
- ThreadPoolExecutor: ping e push ora in parallelo (tempo ~= server piu' lento,
  non la somma). Un server morto non blocca piu' gli altri.
- Fast-fail per operazioni interattive (ping/info/download): max_retries=0,
  niente retry-storm.
- Feedback live: callback on_each() aggiorna il dialog server-per-server
  (thread-safe via pyqtSignal di BalWaitingDialog.update).
- Push transazioni: parallelo ma con retry per-server mantenuti (no perdita tx).

File:
- bal/core/willexecutors.py: send_request(+max_retries,+retry_sleep),
  get_info_task fast-fail, NEW ping_servers_parallel(), push_transactions_parallel(),
  DEFAULT_TIMEOUT=5.
- bal/gui/qt/window.py: ping_willexecutors_task + push_transactions_to_willexecutors
  riscritti su helper paralleli con feedback live; fetch_will_executors_list fast-fail.
- bal/core/util.py: BUGFIX get_value_amount usava in_output (bool) invece di
  din_output (tupla) -> TypeError. Scoperto dai test ufficiali Gitea.

Test (contro il codice refactor):
- pytest tests/ ufficiali: 117 core + 65 gui = 182 passed.
- smoke/external_zip/windows_overflow/gui_fixes: OK.
- parallel_ping_test (nuovo): 0.50s per 8 server vs ~4.00s sequenziale.
- ruff: nessun nuovo problema introdotto (codice nuovo PEP8-compliant).

Aggiunti i test ufficiali del repo Gitea + REPORT_NETWORKING_PARALLELO.md.
This commit is contained in:
GenSpark AI Developer
2026-06-15 14:29:04 +00:00
parent 3c44a29f84
commit 4c5726571e
16 changed files with 2843 additions and 59 deletions

View File

@@ -0,0 +1,103 @@
"""
Tests for ``bal.gui.qt.window_utils``.
Covers top_level_of, bring_to_front, stop_thread, show_modal, show_on_top.
Run:
QT_QPA_PLATFORM=offscreen python3 tests/test_gui_window_utils.py
"""
import sys
sys.path.insert(0, __file__.rsplit("/", 2)[0])
from PyQt6.QtCore import QTimer
from PyQt6.QtWidgets import QApplication, QDialog, QWidget
from bal.gui.qt.window_utils import (
bring_to_front, show_modal, show_on_top, stop_thread, top_level_of,
)
_app = QApplication.instance() or QApplication(sys.argv)
# ------------------------------------------------------------------ #
# top_level_of
# ------------------------------------------------------------------ #
def test_top_level_of_child():
w = QWidget()
child = QWidget(w)
assert top_level_of(child) is w
def test_top_level_of_plain_widget():
w = QWidget()
assert top_level_of(w) is w.window()
def test_top_level_of_none():
assert top_level_of(None) is None
def test_top_level_of_dialog():
d = QDialog()
assert top_level_of(d) is d.window()
# ------------------------------------------------------------------ #
# bring_to_front
# ------------------------------------------------------------------ #
def test_bring_to_front_dialog():
d = QDialog()
bring_to_front(d)
def test_bring_to_front_widget():
w = QWidget()
bring_to_front(w)
# ------------------------------------------------------------------ #
# stop_thread
# ------------------------------------------------------------------ #
def test_stop_thread_none():
stop_thread(None)
# ------------------------------------------------------------------ #
# show_modal / show_on_top (smoke tests - can't check exec result)
# ------------------------------------------------------------------ #
def test_show_modal_no_crash():
d = QDialog()
QTimer.singleShot(0, d.reject)
result = show_modal(d)
assert result == QDialog.DialogCode.Rejected
def test_show_on_top_no_crash():
d = QDialog()
result = show_on_top(d, modal_to_window=True)
assert result is d
d.close()
def test_show_on_top_non_modal():
d = QDialog()
result = show_on_top(d, modal_to_window=False)
assert result is d
d.close()
# ------------------------------------------------------------------ #
# Main
# ------------------------------------------------------------------ #
if __name__ == "__main__":
for name in sorted(dir()):
if name.startswith("test_"):
globals()[name]()
print(f" [OK] {name}")
print("[OK] All window_utils tests passed")