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:
@@ -38,6 +38,7 @@ dev = [
|
||||
"ruff>=0.1",
|
||||
"mypy>=1.0",
|
||||
"types-PyYAML>=6.0",
|
||||
"pandas-stubs>=2.0",
|
||||
]
|
||||
|
||||
[project.scripts]
|
||||
|
||||
@@ -217,10 +217,13 @@ class InstrumentServer:
|
||||
response = instrument.process(command)
|
||||
|
||||
# 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:
|
||||
writer.write(f"{response}\n".encode())
|
||||
await writer.drain()
|
||||
logger.debug("Port %d sent: %s", port, response)
|
||||
else:
|
||||
logger.debug("Port %d sent: <empty response>", port)
|
||||
|
||||
except asyncio.CancelledError:
|
||||
logger.debug("Client handler cancelled for port %d", port)
|
||||
|
||||
Reference in New Issue
Block a user