From f086433e83350c936a8971c6c4d537780ee67cf8 Mon Sep 17 00:00:00 2001 From: Tehom Date: Thu, 24 Nov 2016 04:11:49 -0500 Subject: [PATCH] These fixed the exceptions that popped up for me when stopping the evennia process on Windows - believe it or not, the wholly redundant try/except block for printing the success message in evenna_launcher actually removed a traceback.. But since Windows seems incredibly finicky, it'd probably be a good idea to see if it breaks anything for someone else using Windows first. --- evennia/server/evennia_launcher.py | 8 ++++-- evennia/server/evennia_runner.py | 40 ++++++++++++++++-------------- 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/evennia/server/evennia_launcher.py b/evennia/server/evennia_launcher.py index f0aad39ed..cae55bf81 100644 --- a/evennia/server/evennia_launcher.py +++ b/evennia/server/evennia_launcher.py @@ -732,8 +732,12 @@ def kill(pidfile, signal=SIG, succmsg="", errmsg="", "The PID file 'server/%(pidfile)s' seems stale. "\ "Try removing it." % {'pid': pid, 'pidfile': pidfile}) return - print("Evennia:", succmsg) - return + try: + print("Evennia:", succmsg) + return + except KeyboardInterrupt: + print("Evennia:", succmsg) + return print("Evennia:", errmsg) diff --git a/evennia/server/evennia_runner.py b/evennia/server/evennia_runner.py index 8035d5504..ce9299f4f 100644 --- a/evennia/server/evennia_runner.py +++ b/evennia/server/evennia_runner.py @@ -185,26 +185,30 @@ def start_services(server_argv, portal_argv): while True: # this blocks until something is actually returned. + from twisted.internet.error import ReactorNotRunning try: - message, rc = processes.get() - except KeyboardInterrupt: - # this only matters in interactive mode + try: + message, rc = processes.get() + except KeyboardInterrupt: + # this only matters in interactive mode + break + + # restart only if process stopped cleanly + if (message == "server_stopped" and int(rc) == 0 and + get_restart_mode(SERVER_RESTART) in ("True", "reload", "reset")): + print(PROCESS_RESTART.format(component="Server")) + SERVER = thread.start_new_thread(server_waiter, (processes, )) + continue + + # normally the portal is not reloaded since it's run as a daemon. + if (message == "portal_stopped" and int(rc) == 0 and + get_restart_mode(PORTAL_RESTART) == "True"): + print(PROCESS_RESTART.format(component="Portal")) + PORTAL = thread.start_new_thread(portal_waiter, (processes, )) + continue + break + except ReactorNotRunning: break - - # restart only if process stopped cleanly - if (message == "server_stopped" and int(rc) == 0 and - get_restart_mode(SERVER_RESTART) in ("True", "reload", "reset")): - print(PROCESS_RESTART.format(component="Server")) - SERVER = thread.start_new_thread(server_waiter, (processes, )) - continue - - # normally the portal is not reloaded since it's run as a daemon. - if (message == "portal_stopped" and int(rc) == 0 and - get_restart_mode(PORTAL_RESTART) == "True"): - print(PROCESS_RESTART.format(component="Portal")) - PORTAL = thread.start_new_thread(portal_waiter, (processes, )) - continue - break def main():