Sfoglia il codice sorgente

Improving exit function

Penta 5 anni fa
parent
commit
b2875f2879
1 ha cambiato i file con 6 aggiunte e 3 eliminazioni
  1. 6 3
      myanimebot.py

+ 6 - 3
myanimebot.py

@@ -34,8 +34,9 @@ if not sys.version_info[:2] >= (3, 7):
 	exit(1)
 
 
-def exit_app():
-	logging.info("Closing all tasks...")
+def exit_app(signum=None, frame=None):
+	globals.logger.debug("Received signal {}".format(signum))
+	globals.logger.info("Closing all tasks...")
 	
 	if globals.MAL_ENABLED:
 		globals.task_feed.cancel()
@@ -45,7 +46,7 @@ def exit_app():
 
 	globals.task_thumbnail.cancel()
 	globals.task_gameplayed.cancel()
-
+	
 	globals.logger.critical("Script halted.")
 
 	# Closing all ressources
@@ -53,6 +54,8 @@ def exit_app():
 	globals.log_cursor.close()
 	globals.log_conn.close()
 
+	exit(int(signum))
+
 
 # Starting main function	
 if __name__ == "__main__":