brata-hsdc / brata.station

Automatically exported from code.google.com/p/brata.station
Apache License 2.0
0 stars 0 forks source link

ConnectionManager blocks #11

Open jawaad-ahmad opened 9 years ago

jawaad-ahmad commented 9 years ago

ConnectionManager's run method calls Tornado's IOLoop start method for the event loop for processing the HTTP server on port 5000 to listen for messages from the Master Server.

IOLoop.instance().start() blocks, so the main loop of the thread never continues.

This works fine for the initial connection whenever the Master Server comes up and the station initially joins, but the purpose of the loop was to periodically call join to check whether or not the Master Server was still up.

Need to somehow start the HTTP server without blocking, or perhaps push the TCP server start code into yet another separate thread and allow that thread to block with its own event loop while ConnectionManager's loop continues.

This continues brata-hsdc/brata#54.

ellerychan commented 8 years ago

Does the station need to know whether the MS is still up?

To let the MS know that the station is still up, we have the Heartbeat message (not implemented in the station yet, I think).

It seems proper that the server thread should block, listen for, and dispatch incoming messages. A periodic outgoing message should probably come from another thread.