Restart by default

darcs-hash:20080821204012-86b55-4d943df45b93edc83b4177a9a8fdb1ec85af9fc6.gz
This commit is contained in:
David Rousselie
2008-08-21 22:40:12 +02:00
parent 391ce083e0
commit d95702a940
2 changed files with 10 additions and 9 deletions

View File

@@ -673,7 +673,8 @@ class JCLComponent(Component, object):
timer_thread = threading.Thread(target=self.time_handler,
name="TimerThread")
timer_thread.start()
wait_before_restart = 0
wait_before_restart = 5
self._restart = True
try:
try:
while (self.running and self.stream
@@ -686,10 +687,11 @@ class JCLComponent(Component, object):
self.__logger.info("Connection failed, restarting.")
return (True, 5)
finally:
if self.running:
self._restart = True
wait_before_restart = 5
self.running = False
if not self.running:
self._restart = False
wait_before_restart = 0
else:
self.running = False
timer_thread.join(JCLComponent.timeout)
self.wait_event.set()
if self.stream and not self.stream.eof \

View File

@@ -2952,7 +2952,7 @@ class JCLComponent_run_TestCase(JCLComponent_TestCase):
def test_run_restart(self):
"""Test main loop execution with restart"""
def do_nothing():
self.comp.running = False
self.comp.stream.eof = True
return
self.comp.handle_tick = do_nothing
self.comp.time_unit = 1
@@ -2961,12 +2961,11 @@ class JCLComponent_run_TestCase(JCLComponent_TestCase):
self.comp.stream_class = MockStreamNoConnect
self.comp.restart = True
(result, time_to_wait) = self.comp.run()
self.assertEquals(time_to_wait, 0)
self.assertEquals(time_to_wait, 5)
self.assertTrue(result)
self.assertTrue(self.comp.stream.connection_started)
threads = threading.enumerate()
self.assertEquals(len(threads), 1)
self.assertTrue(self.comp.stream.connection_stopped)
if self.comp.queue.qsize():
raise self.comp.queue.get(0)
@@ -3012,7 +3011,7 @@ class JCLComponent_run_TestCase(JCLComponent_TestCase):
self.assertEquals(len(threads), 1)
self.assertFalse(self.comp.stream.connection_stopped)
def test_run_unhandled_error(self):
def test_run_unhandled_error(self): # TODO : why it works ?
"""Test main loop unhandled error from a component handler"""
def do_nothing():
return