def main(): sio.connect('https://ishoal.ink/') ishoalc.wait_for_switch() if ishoalc.should_stop(): sio.disconnect() return def on_switch_change(): pulse() threading.Thread(target=ishoalc.on_switch_chg_threadfn, args=(on_switch_change,), name='py_switch_chg').start() def periodic_pulse_threadfn(): while not ishoalc.should_stop(): ishoalc.sleep(10 * 1000) pulse() threading.Thread(target=periodic_pulse_threadfn, name='py_pulse').start() # Python is dumb that signal handlers must execute on main thread :( # if we ishoalc.sleep(-1) then signal handler will never execute # wake up every 100ms to check for signals while not ishoalc.should_stop(): ishoalc.sleep(100) sio.disconnect()
def main(): global loop loop = handshake.start_handshaker() new_socketio() def on_switch_change(): if g_sio: g_sio.disconnect() threading.Thread(target=ishoalc.on_switch_chg_threadfn, args=(on_switch_change, ), name='py_switch_chg').start() # Python is dumb that signal handlers must execute on main thread :( # if we ishoalc.sleep(-1) then signal handler will never execute # wake up every 100ms to check for signals while not ishoalc.should_stop(): ishoalc.sleep(100) global finalizing finalizing = True if g_sio: g_sio.disconnect() loop.call_soon_threadsafe(loop.stop)
def on_disconnect(): for switchip in all_connections: ishoalc.delete_connection(switchip) global g_sio g_sio = None all_connections.clear() print('Disconnected', file=remotes_log) ishoalc.sleep(100) if not finalizing: new_socketio()
def periodic_pulse_threadfn(): while not ishoalc.should_stop(): ishoalc.sleep(10 * 1000) pulse()