Skip to content

Commit

Permalink
Make usercode terminate properly when resetting the world
Browse files Browse the repository at this point in the history
  • Loading branch information
WillB97 committed Aug 18, 2024
1 parent 36d3fc0 commit 46adc9c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions simulator/modules/sbot_interface/socket_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
from __future__ import annotations

import logging
import os
import select
import signal
import socket
import sys
from threading import Event
Expand Down Expand Up @@ -193,6 +195,13 @@ def run(self) -> None:
except Exception as e:
LOGGER.exception(f"Failure in simulated boards: {e}")

LOGGER.info('Stopping server')
for device in self.devices:
device.close()

# Stop the usercode
os.kill(os.getpid(), signal.SIGINT)

def links(self) -> dict[str, dict[str, str]]:
"""Return a mapping of asset tags to ports, grouped by board type."""
return {
Expand Down

0 comments on commit 46adc9c

Please sign in to comment.