Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions summoner/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1436,8 +1436,8 @@ async def handle_session(self, host: str = '127.0.0.1', port: int = 8888):

# Deregister this session and its children from active tasks
async with self.tasks_lock:
if task is not None:
self.active_tasks.discard(task)
if current_task is not None:
self.active_tasks.discard(current_task)

# Check whether we should quit or loop back to travel to the next server (agent migration)
async with self.connection_lock:
Expand All @@ -1459,7 +1459,21 @@ def set_termination_signals(self):
"""
if platform.system() != "Windows":
for sig in (signal.SIGINT, signal.SIGTERM):
self.loop.add_signal_handler(sig, lambda: self.shutdown())
self.loop.add_signal_handler(sig, self.shutdown)
else:
def _handler(sig, frame):
# thread-safe: schedule shutdown on the event loop
try:
self.loop.call_soon_threadsafe(self.shutdown)
except RuntimeError:
pass
signal.signal(signal.SIGINT, _handler)
# SIGTERM exists on Windows in Python, but behavior varies by launcher
if hasattr(signal, "SIGTERM"):
try:
signal.signal(signal.SIGTERM, _handler)
except Exception:
pass

async def _wait_for_registration(self):
"""
Expand Down