I am following the example in this thread to try to publish messages to a remote VOLTTRON platform, and it is working fine when the remote platform is running and set-up correctly. However, when the remote platform is not running, the publish function remains blocking forever and won't time out. This prevents detection of when the remote platform is not running, and also prevents execution of rest of the code.
from volttron.platform.vip.agent import Core, Agent
import gevent
def vip_publish(topic,message, address=None):
retry = 3
while retry>0:
pub_agent = Agent(address=address)
my_event = gevent.event.Event()
pub_agent.core.onstart.connect(lambda *a, **kw: my_event.set(),my_event)
agent_thread = gevent.spawn(pub_agent.core.run)
my_event.wait()
try:
#The following line remains blocking forever when remote volttron platform is not running
pub_agent.vip.pubsub.publish(peer='pubsub', topic=topic, message=message).get(timeout=1)
except gevent.Timeout:
print "Time-out"
retry -= 1
else:
retry = 0
agent_thread.kill()