Beispiel #1
0
 def close(self):
     if self.__connection is not None:
         try:
             self.__connection.close()
         except:
             # On some condition such as Ubuntu 14.04, the above close()
             # raises an exception when the rabbitmq-server is stopped.
             haplib.handle_exception()
         self.__connection = None
Beispiel #2
0
 def test_handle_exception(self):
     obj = Gadget()
     try:
         raise obj
     except:
         exctype, value = haplib.handle_exception()
     self.assertEquals(Gadget, exctype)
     self.assertEquals(obj, value)
 def test_handle_exception(self):
     obj = Gadget()
     try:
         raise obj
     except:
         exctype, value = haplib.handle_exception()
     self.assertEquals(Gadget, exctype)
     self.assertEquals(obj, value)
Beispiel #4
0
 def __call__(self):
     while True:
         try:
             self.__run()
         except:
             raises = (KeyboardInterrupt, AssertionError, SystemExit)
             exctype, value = haplib.handle_exception(raises=raises)
         else:
             break
         #TODO: make sure poller and receiver has been killed.
         logging.info("Rerun after %d sec" % self.__error_sleep_time)
         time.sleep(self.__error_sleep_time)