mirror of
https://github.com/fishyboteso/fishyboteso.git
synced 2024-08-30 18:32:13 +00:00
handling keyboard interupt and exiting main thread safely
kindof related to #104
This commit is contained in:
parent
b6e543a9e3
commit
4e55c88629
@ -53,43 +53,46 @@ def initialize(window_to_hide):
|
||||
helper.install_required_addons()
|
||||
|
||||
|
||||
def on_gui_load(gui, finish_splash, logger):
|
||||
finish_splash()
|
||||
update_dialog.check_update(gui)
|
||||
logger.connect(gui)
|
||||
|
||||
|
||||
def main():
|
||||
print("launching please wait...")
|
||||
|
||||
config.init()
|
||||
if not check_eula():
|
||||
return
|
||||
|
||||
finish_splash = splash.start()
|
||||
logger = GuiLogger()
|
||||
config.start_backup_scheduler()
|
||||
active.init()
|
||||
hotkey.init()
|
||||
|
||||
def on_gui_load():
|
||||
finish_splash()
|
||||
update_dialog.check_update(gui)
|
||||
logger.connect(gui)
|
||||
|
||||
window_to_hide = win32gui.GetForegroundWindow()
|
||||
|
||||
bot = EngineEventHandler(lambda: gui)
|
||||
gui = GUI(lambda: bot, on_gui_load)
|
||||
gui = GUI(lambda: bot, lambda: on_gui_load(gui, finish_splash, logger))
|
||||
window_to_hide = win32gui.GetForegroundWindow()
|
||||
logger = GuiLogger()
|
||||
hotkey.init()
|
||||
active.init()
|
||||
|
||||
hotkey.start()
|
||||
try:
|
||||
config.init()
|
||||
if not check_eula():
|
||||
return
|
||||
|
||||
logging.info(f"Fishybot v{fishy.__version__}")
|
||||
initialize(window_to_hide)
|
||||
logging.info(f"Fishybot v{fishy.__version__}")
|
||||
|
||||
gui.start()
|
||||
active.start()
|
||||
finish_splash = splash.start()
|
||||
config.start_backup_scheduler()
|
||||
|
||||
bot.start_event_handler() # main thread loop
|
||||
initialize(window_to_hide)
|
||||
|
||||
hotkey.stop()
|
||||
active.stop()
|
||||
config.stop()
|
||||
bot.stop()
|
||||
hotkey.start()
|
||||
gui.start()
|
||||
active.start()
|
||||
|
||||
bot.start_event_handler() # main thread loop
|
||||
except KeyboardInterrupt as e:
|
||||
...
|
||||
finally:
|
||||
gui._destroyed = True
|
||||
hotkey.stop()
|
||||
active.stop()
|
||||
config.stop()
|
||||
bot.stop()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -14,12 +14,12 @@ class active:
|
||||
return
|
||||
|
||||
active._scheduler = EventScheduler()
|
||||
active._scheduler.start()
|
||||
logging.debug("active scheduler initialized")
|
||||
|
||||
@staticmethod
|
||||
def start():
|
||||
web.ping()
|
||||
active._scheduler.start()
|
||||
active._scheduler.enter_recurring(60, 1, web.ping)
|
||||
logging.debug("active scheduler started")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user