From 217aa334ba382c45ce565ce534c52a6401ce73f0 Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Sun, 2 Jan 2022 14:45:11 -0300 Subject: send_packet_now - Retry up to 5 times when facing an error with ws.send --- game/01_init.rpy | 1 + game/04_init.rpy | 26 +++++++++++++++----------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/game/01_init.rpy b/game/01_init.rpy index 7015bc5..7995f85 100644 --- a/game/01_init.rpy +++ b/game/01_init.rpy @@ -58,6 +58,7 @@ init -3 python: SSL_IS_BROKEN=False CERT_NONE=0 INT_MAX=2147483647 + MAX_RETRIES = 5 debug=copy.copy(config.developer) TERMINATE=False CLOSING=False diff --git a/game/04_init.rpy b/game/04_init.rpy index 85e153b..6724720 100644 --- a/game/04_init.rpy +++ b/game/04_init.rpy @@ -103,19 +103,23 @@ init python: global ws, tr_load, tr_val, tr_busy, TERMINATE, CLOSING stdout("Sending: %s" % packet) - try: - ws.send(get_token() + ";" + packet + ";" + args) - except: - traceback.print_exc() - stdout("FATAL ERROR, packet was not sent!") + cnt = 0 + while cnt < MAX_RETRIES: + cnt+=1 try: - renpy.call_screen("msgbox", - "An unrecoverable error happened.\nPlease close and re-open the app.") + ws.send(get_token() + ";" + packet + ";" + args) + break # Success attained, continue except: - pass - TERMINATE=True - if not CLOSING: - renpy.quit(relaunch=True) + traceback.print_exc() + stdout("FATAL ERROR, packet was not sent!") + try: + renpy.call_screen("msgbox", + "An unrecoverable error happened.\nPlease close and re-open the app.") + except: + pass + TERMINATE=True + if not CLOSING: + renpy.quit(relaunch=True) return -- cgit v1.2.3-60-g2f50