Skip to content

Commit

Permalink
Fix: broker crash when sub process gt down and are not catch at the b…
Browse files Browse the repository at this point in the history
…egining of the loop. fix #1350
  • Loading branch information
naparuba committed Nov 12, 2014
1 parent 06f382b commit 466d359
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions shinken/daemons/brokerdaemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -710,11 +710,23 @@ def do_loop_turn(self):
# We put to external queues broks that was not already send
t0 = time.time()
# We are sending broks as a big list, more efficient than one by one
queues = self.modules_manager.get_external_to_queues()
ext_modules = self.modules_manager.get_external_instances()
to_send = [b for b in self.broks if getattr(b, 'need_send_to_ext', True)]

for q in queues:
q.put(to_send)
# Send our pack to all external modules to_q queue so they can get the wole packet
# beware, the sub-process/queue can be die/close, so we put to restart the whole module
# instead of killing ourself :)
for mod in ext_modules:
try:
mod.to_q.put(to_send)
except Exception, exp:
# first we must find the modules
logger.debug(str(exp.__dict__))
logger.warning("The mod %s queue raise an exception: %s, I'm tagging it to restart later", mod.get_name(), str(exp))
logger.warning("Exception type: %s", type(exp))
logger.warning("Back trace of this kill: %s", traceback.format_exc())
self.modules_manager.set_to_restart(mod)


# No more need to send them
for b in to_send:
Expand Down

0 comments on commit 466d359

Please sign in to comment.