From 9bd6a5501475b74784ccf60bbb493030a5f02f0f Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Thu, 17 Dec 2020 17:48:44 -0300 Subject: Stop running supervisor() after we are done in hopes to lower CPU usage. ...It did not lower the CPU use nor avoided the AttributeError =/ So, uh, yes, restart is still broken --- game/04_init.rpy | 32 ++++++-------------------------- 1 file changed, 6 insertions(+), 26 deletions(-) (limited to 'game') diff --git a/game/04_init.rpy b/game/04_init.rpy index 86a269a..99359f6 100644 --- a/game/04_init.rpy +++ b/game/04_init.rpy @@ -141,17 +141,16 @@ init python: def send_packet(packet, args=""): global tr_cmd, tr_busy, tr_load schedule_packet() - tr_cmd=[packet, args] + send_packet_now(packet, args) tr_val = wait_packet() return - # This is not really required, just makes we use two threads - # instead of one? tr_busy is handled by shcedule_packet() which is - # summoned by send_packet() already, so it should not be needed - # I guess it could be handful to auto-restart connection laterâ„¢? + # In past, this would keep running, in hopes of catching the program quit + # and being able to kill the threads... But well, it worked poorly. + # Still called "supervisor" but all it does now is init. # sslopt={"cert_reqs": CERT_NONE}) def supervisor(use_ssl): - global tr_load, tr_val, tr_busy, tr_cmd, ws + global ws stdout(_("Opening new socket...")) if use_ssl: ws = GameClient("wss://"+HOST+":61000") @@ -160,25 +159,6 @@ init python: ws.connect() renpy.invoke_in_thread(ws.run_forever) # May be problematic stdout("Connection established!") - - # Begin loop - while True: - try: - if tr_cmd[0] != "": - #schedule_packet() - send_packet_now(tr_cmd[0], tr_cmd[1]) - tr_cmd=["", ""] - # Main thread is the one waiting, not us - time.sleep(0.02) - pass - except NameError: - print("NameError, perhaps the program has terminated?") - break - try: - ws.close() - except: - pass - - # Close the supervisor module + # The supervisor module is now uneeded as thread was cast return -- cgit v1.2.3-60-g2f50