Fix TCP server response handling and add pandas-stubs

- Always send a response (even empty) to prevent client timeouts
- Add pandas-stubs to dev dependencies for mypy type checking
- Server now sends newline-terminated response for all commands

This fixes the mypy CI failure. Integration test failures still need
investigation - likely due to event loop blocking when mixing sync/async.
This commit is contained in:
2025-10-01 17:37:36 +00:00
parent b03eb8c89f
commit 32e9994a2b
2 changed files with 6 additions and 2 deletions

View File

@@ -38,6 +38,7 @@ dev = [
"ruff>=0.1", "ruff>=0.1",
"mypy>=1.0", "mypy>=1.0",
"types-PyYAML>=6.0", "types-PyYAML>=6.0",
"pandas-stubs>=2.0",
] ]
[project.scripts] [project.scripts]

View File

@@ -217,10 +217,13 @@ class InstrumentServer:
response = instrument.process(command) response = instrument.process(command)
# Send response with newline terminator # Send response with newline terminator
# Always send a response, even if empty (for acknowledgment)
writer.write(f"{response}\n".encode())
await writer.drain()
if response: if response:
writer.write(f"{response}\n".encode())
await writer.drain()
logger.debug("Port %d sent: %s", port, response) logger.debug("Port %d sent: %s", port, response)
else:
logger.debug("Port %d sent: <empty response>", port)
except asyncio.CancelledError: except asyncio.CancelledError:
logger.debug("Client handler cancelled for port %d", port) logger.debug("Client handler cancelled for port %d", port)