Recupera movimenti barcode dopo risposta persa

This commit is contained in:
2026-07-04 09:05:14 +02:00
parent e575c748cc
commit f4e73bd5b9
3 changed files with 130 additions and 12 deletions

View File

@@ -581,17 +581,15 @@ class BarcodeClientApp:
result = future.result()
except Exception as exc:
log_exception("Barcode WMS", exc, context="barcode async operation")
current = self.service.state
current.status_text = "Transazione non completata, ripeti l'operazione."
current.status_color = "#f4cccc"
self._apply_state(current)
messagebox.showerror(
"Barcode WMS",
"Operazione non completata.\n\n"
"Ripeti la lettura o avvisa il responsabile.\n"
"Il dettaglio tecnico e' stato scritto nel log.",
parent=self.root,
self._set_busy(True, "Verifico esito...")
self._pending = asyncio.run_coroutine_threadsafe(
self.service.reconcile_after_submit_exception(
scanned_pallet=self.scanned_var.get(),
destination_barcode=self.destination_var.get(),
),
self.loop,
)
self.root.after(40, lambda err=exc: self._poll_recovery_future(err))
return
if isinstance(result, BarcodeActionResult):
@@ -601,6 +599,46 @@ class BarcodeClientApp:
elif isinstance(result, BarcodeViewState):
self._apply_state(result)
def _show_transaction_error(self) -> None:
messagebox.showerror(
"Barcode WMS",
"Operazione non completata.\n\n"
"Ripeti la lettura o avvisa il responsabile.\n"
"Il dettaglio tecnico e' stato scritto nel log.",
parent=self.root,
)
def _poll_recovery_future(self, original_exception: Exception) -> None:
if self._pending is None:
self._set_busy(False)
self._show_transaction_error()
return
if not self._pending.done():
self.root.after(40, lambda err=original_exception: self._poll_recovery_future(err))
return
future = self._pending
self._pending = None
self._set_busy(False)
try:
result = future.result()
except Exception as exc:
log_exception("Barcode WMS", exc, context=f"barcode recovery after {original_exception!r}")
current = self.service.state
current.status_text = "Transazione non completata, ripeti l'operazione."
current.status_color = "#f4cccc"
self._apply_state(current)
self._show_transaction_error()
return
if isinstance(result, BarcodeActionResult):
self._apply_state(result.state)
if not result.ok:
self.root.bell()
self._show_transaction_error()
elif isinstance(result, BarcodeViewState):
self._apply_state(result)
def _shutdown(self) -> None:
try:
if self._pending is not None and not self._pending.done():