INNER CODE UNIT · Python
send_command_to_mt5
codedpro/mt5-trade-split-manager · server.py:206
def send_command_to_mt5(command: dict, timeout: int = REQUEST_TIMEOUT) -> dict:
"""Queue a command and wait for its own response. On timeout the command is
abandoned so it will not be executed by the EA on a later poll."""
env = Envelope(command)
command_queue.put(env)
if env.event.wait(timeout):
return env.result
# Timed out: prevent this command from firing late.
env.abandoned = True
raise HTTPException(status_code=504, detail="MT5 timeout - EA not connecting")
@app.get("/")
async def root():
return {"status": "online", "service": "MT5 TCP Bridge"}