parameters: (self, status = False, return_code = None, exit=True)
docstring: Leave threads & timers
  
              In the XplPLugin class, this function will be completed to also activate the xpl hbeat
docstring_summary: Leave threads & timers
docstring_tokens: Leave threads & timers
function: def force_leave(self, status = False, return_code = None, exit=True):
          """ Leave threads & timers
  
              In the XplPLugin class, this function will be completed to also activate the xpl hbeat
          """
          if hasattr(self, "log"):
              self.log.debug(u"force_leave called")
              #self.log.debug(u"the stack is : {0}".format(inspect.stack()))
              #self.log.debug(u"the stack is :")
              #for elt in inspect.stack():
              #    self.log.debug(u"    {0}".format(elt))
  
          # try to stop the thread
          try:
              self.get_stop().set()
          except AttributeError:
              pass
  
          if return_code != None:
              self.set_return_code(return_code)
              self.log.info("Return code set to {0} when calling force_leave()".format(return_code))
  
  
          # avoid ready() to be launched
          self.dont_run_ready = True
          # stop IOLoop
          #try:
          #    IOLoop.instance().start()
          #except:
          #    pass
          # send stopped status over the MQ
          if status:
              self._set_status(status, u"Handle force leave")
          else:
              self._set_status(STATUS_STOPPED, u"Stopped by force leave")
  
  
          if hasattr(self, "_timers"):
              for t in self._timers:
                  if hasattr(self, "log"):
                      self.log.debug(u"Try to stop timer {0}".format(t))
                  t.stop()
                  if hasattr(self, "log"):
                      self.log.debug(u"Timer stopped {0}".format(t))
  
          if hasattr(self, "_stop_cb"):
              for cb in self._stop_cb:
                  if hasattr(self, "log"):
                      self.log.debug(u"Calling stop additionnal method : {0} ".format(cb.__name__))
                  cb()
  
          if hasattr(self, "_threads"):
              for t in self._threads:
                  if hasattr(self, "log"):
                      self.log.debug(u"Try to stop thread {0}".format(t))
                  try:
                      t.join()
                  except RuntimeError:
                      pass
                  if hasattr(self, "log"):
                      self.log.debug(u"Thread stopped {0}".format(t))
                  #t._Thread__stop()
  
          #Finally, we try to delete all remaining threads
          for t in threading.enumerate():
              if t != threading.current_thread() and t.__class__ != threading._MainThread:
                  if hasattr(self, "log"):
                      self.log.info(u"The thread {0} was not registered, killing it".format(t.name))
                  t.join()
                  if hasattr(self, "log"):
                      self.log.info(u"Thread {0} stopped.".format(t.name))
  
          if threading.activeCount() > 1:
              if hasattr(self, "log"):
                  self.log.warn(u"There are more than 1 thread remaining : {0}".format(threading.enumerate()))
          if exit :
              sys.exit()
function_tokens: def force_leave ( self , status = False , return_code = None , exit = True ) : if hasattr ( self , "log" ) : self . log . debug ( u"force_leave called" ) #self.log.debug(u"the stack is : {0}".format(inspect.stack())) #self.log.debug(u"the stack is :") #for elt in inspect.stack(): #    self.log.debug(u"    {0}".format(elt)) # try to stop the thread try : self . get_stop ( ) . set ( ) except AttributeError : pass if return_code != None : self . set_return_code ( return_code ) self . log . info ( "Return code set to {0} when calling force_leave()" . format ( return_code ) ) # avoid ready() to be launched self . dont_run_ready = True # stop IOLoop #try: #    IOLoop.instance().start() #except: #    pass # send stopped status over the MQ if status : self . _set_status ( status , u"Handle force leave" ) else : self . _set_status ( STATUS_STOPPED , u"Stopped by force leave" ) if hasattr ( self , "_timers" ) : for t in self . _timers : if hasattr ( self , "log" ) : self . log . debug ( u"Try to stop timer {0}" . format ( t ) ) t . stop ( ) if hasattr ( self , "log" ) : self . log . debug ( u"Timer stopped {0}" . format ( t ) ) if hasattr ( self , "_stop_cb" ) : for cb in self . _stop_cb : if hasattr ( self , "log" ) : self . log . debug ( u"Calling stop additionnal method : {0} " . format ( cb . __name__ ) ) cb ( ) if hasattr ( self , "_threads" ) : for t in self . _threads : if hasattr ( self , "log" ) : self . log . debug ( u"Try to stop thread {0}" . format ( t ) ) try : t . join ( ) except RuntimeError : pass if hasattr ( self , "log" ) : self . log . debug ( u"Thread stopped {0}" . format ( t ) ) #t._Thread__stop() #Finally, we try to delete all remaining threads for t in threading . enumerate ( ) : if t != threading . current_thread ( ) and t . __class__ != threading . _MainThread : if hasattr ( self , "log" ) : self . log . info ( u"The thread {0} was not registered, killing it" . format ( t . name ) ) t . join ( ) if hasattr ( self , "log" ) : self . log . info ( u"Thread {0} stopped." . format ( t . name ) ) if threading . activeCount ( ) > 1 : if hasattr ( self , "log" ) : self . log . warn ( u"There are more than 1 thread remaining : {0}" . format ( threading . enumerate ( ) ) ) if exit : sys . exit ( )