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,12 +241,13 @@ class Session(object):
time.ctime())) time.ctime()))
self.writestate(state) self.writestate(state)
self.runhook(state) self.runhook(state)
if self.isconnected() and sendevent: if sendevent:
tlvdata = "" tlvdata = ""
tlvdata += coreapi.CoreEventTlv.pack(coreapi.CORE_TLV_EVENT_TYPE, tlvdata += coreapi.CoreEventTlv.pack(coreapi.CORE_TLV_EVENT_TYPE,
state) state)
msg = coreapi.CoreEventMessage.pack(0, tlvdata) msg = coreapi.CoreEventMessage.pack(0, tlvdata)
# send Event Message to connected handlers (e.g. GUI) # send Event Message to connected handlers (e.g. GUI)
if self.isconnected():
try: try:
if returnevent: if returnevent:
replies.append(msg) replies.append(msg)

View file

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