fixed issues with shutting down a distributed batch mode

This commit is contained in:
tgoff0 2015-05-22 00:54:28 +00:00
parent 5b36181956
commit ea4f6ba518
2 changed files with 11 additions and 8 deletions

View file

@ -241,19 +241,20 @@ class Session(object):
time.ctime()))
self.writestate(state)
self.runhook(state)
if self.isconnected() and sendevent:
if sendevent:
tlvdata = ""
tlvdata += coreapi.CoreEventTlv.pack(coreapi.CORE_TLV_EVENT_TYPE,
state)
msg = coreapi.CoreEventMessage.pack(0, tlvdata)
# send Event Message to connected handlers (e.g. GUI)
try:
if returnevent:
replies.append(msg)
else:
self.broadcastraw(None, msg)
except Exception, e:
self.warn("Error sending Event Message: %s" % e)
if self.isconnected():
try:
if returnevent:
replies.append(msg)
else:
self.broadcastraw(None, msg)
except Exception, e:
self.warn("Error sending Event Message: %s" % e)
# also inform slave servers
tmp = self.broker.handlerawmsg(msg)
return replies

View file

@ -1245,6 +1245,8 @@ class CoreRequestHandler(SocketServer.BaseRequestHandler):
self.info("request to terminate session %s" % sid)
session.setstate(state=coreapi.CORE_EVENT_DATACOLLECT_STATE,
info=True, sendevent=True)
session.setstate(state=coreapi.CORE_EVENT_SHUTDOWN_STATE,
info=True, sendevent=True)
session.shutdown()
else:
self.warn("unhandled session flags for session %s" % sid)