mirror of
https://github.com/ArchipelagoMW/Archipelago.git
synced 2026-03-07 15:13:52 -08:00
MultiServer: fix Windows compatibility (#6010)
This commit is contained in:
@@ -21,7 +21,7 @@ import time
|
|||||||
import typing
|
import typing
|
||||||
import weakref
|
import weakref
|
||||||
import zlib
|
import zlib
|
||||||
from signal import SIGINT, SIGTERM
|
from signal import SIGINT, SIGTERM, signal
|
||||||
|
|
||||||
import ModuleUpdate
|
import ModuleUpdate
|
||||||
|
|
||||||
@@ -2742,12 +2742,23 @@ async def main(args: argparse.Namespace):
|
|||||||
ctx.shutdown_task = asyncio.create_task(auto_shutdown(ctx, [console_task]))
|
ctx.shutdown_task = asyncio.create_task(auto_shutdown(ctx, [console_task]))
|
||||||
|
|
||||||
def stop():
|
def stop():
|
||||||
|
try:
|
||||||
for remove_signal in [SIGINT, SIGTERM]:
|
for remove_signal in [SIGINT, SIGTERM]:
|
||||||
asyncio.get_event_loop().remove_signal_handler(remove_signal)
|
asyncio.get_event_loop().remove_signal_handler(remove_signal)
|
||||||
|
except NotImplementedError:
|
||||||
|
pass
|
||||||
ctx.commandprocessor._cmd_exit()
|
ctx.commandprocessor._cmd_exit()
|
||||||
|
|
||||||
for signal in [SIGINT, SIGTERM]:
|
def shutdown(signum, frame):
|
||||||
asyncio.get_event_loop().add_signal_handler(signal, stop)
|
stop()
|
||||||
|
|
||||||
|
try:
|
||||||
|
for sig in [SIGINT, SIGTERM]:
|
||||||
|
asyncio.get_event_loop().add_signal_handler(sig, stop)
|
||||||
|
except NotImplementedError:
|
||||||
|
# add_signal_handler is only implemented for UNIX platforms
|
||||||
|
for sig in [SIGINT, SIGTERM]:
|
||||||
|
signal(sig, shutdown)
|
||||||
|
|
||||||
await ctx.exit_event.wait()
|
await ctx.exit_event.wait()
|
||||||
console_task.cancel()
|
console_task.cancel()
|
||||||
|
|||||||
Reference in New Issue
Block a user