1
0
Fork 0
mirror of synced 2024-06-02 10:44:40 +12:00

Use signal.disconnect without parameters

This commit is contained in:
lennard 2023-04-08 00:15:19 +02:00 committed by Dummerle
parent 60da656877
commit a06dc7cd0f

View file

@ -159,15 +159,18 @@ class RareLauncher(RareApp):
return
self.server.newConnection.connect(self.new_server_connection)
self.game_process.finished.connect(self.game_finished)
self.game_process.errorOccurred.connect(
self.on_proc_err)
lambda err: self.error_occurred(self.game_process.errorString()))
if self.console:
self.game_process.readyReadStandardOutput.connect(
self.on_log
lambda: self.console.log(
self.game_process.readAllStandardOutput().data().decode("utf-8", "ignore")
)
)
self.game_process.readyReadStandardError.connect(
self.on_err_log
lambda: self.console.error(
self.game_process.readAllStandardError().data().decode("utf-8", "ignore")
)
)
self.console.term.connect(lambda: self.game_process.terminate())
self.console.kill.connect(lambda: self.game_process.kill())
@ -218,6 +221,7 @@ class RareLauncher(RareApp):
else:
self.on_exit(exit_code)
def game_finished(self, exit_code):
self.logger.info("Game finished")
@ -341,29 +345,12 @@ class RareLauncher(RareApp):
else:
self.start_prepare()
def on_log(self):
self.console.log(
self.game_process.readAllStandardOutput().data().decode("utf-8", "ignore")
)
def on_err_log(self):
self.console.error(
self.game_process.readAllStandardError().data().decode("utf-8", "ignore")
)
def on_proc_err(self):
self.error_occurred(self.game_process.errorString())
def stop(self):
if self.console:
self.game_process.readyReadStandardOutput.disconnect(
self.on_log
)
self.game_process.readyReadStandardError.disconnect(
self.on_err_log
)
self.game_process.finished.disconnect(self.game_finished)
self.game_process.errorOccurred.disconnect(self.on_proc_err)
self.game_process.readyReadStandardOutput.disconnect()
self.game_process.readyReadStandardError.disconnect()
self.game_process.finished.disconnect()
self.game_process.errorOccurred.disconnect()
self.logger.info("Stopping server")
try:
self.server.close()
@ -392,7 +379,6 @@ def start_game(args: Namespace):
logger.info(f"{strsignal(s)} received. Stopping")
app.stop()
app.exit(1)
signal(SIGINT, sighandler)
signal(SIGTERM, sighandler)