Browse files

Merge pull request #62 from EvanKrall/bad_status_line

Don't shut down so immediately even if all the runners have come back…
  • Loading branch information...
2 parents f4abf8c + 95d97ec commit fc2f9c728feb10d3f09cdff3ca2c790b8950c0a3 @ayust ayust committed Apr 3, 2012
Showing with 10 additions and 2 deletions.
  1. +2 −0 test/
  2. +3 −0 testify/
  3. +5 −2 testify/
@@ -47,6 +47,8 @@ def run_server(self):
+ shutdown_delay_for_connection_close=0.001,
+ shutdown_delay_for_outstanding_runners=1,
@@ -133,6 +133,9 @@ def parse_test_runner_command_line_args(plugin_modules, args):
parser.add_option('--runner-timeout', action="store", dest="runner_timeout", type="int", default=300, help="How long to wait to wait for activity from a test runner before requeuing the tests it has checked out.")
parser.add_option('--server-timeout', action="store", dest="server_timeout", type="int", default=300, help="How long to wait after the last activity from any test runner before shutting down.")
+ parser.add_option('--server-shutdown-delay', action='store', dest='shutdown_delay_for_connection_close', type="float", default=0.01, help="How long to wait (in seconds) for data to finish writing to sockets before shutting down the server.")
+ parser.add_option('--server-shutdown-delay-outstanding-runners', action='store', dest='shutdown_delay_for_outstanding_runners', type='int', default=5, help="How long to wait (in seconds) for all clients to check for new tests before shutting down the server.")
parser.add_option('--runner-id', action="store", dest="runner_id", type="string", default="%s-%d" % (socket.gethostname(), os.getpid()), help="With --connect, an identity passed to the server on each request. Passed to the server's test reporters. Defaults to <HOST>-<PID>.")
parser.add_option('--replay-json', action="store", dest="replay_json", type="string", default=None, help="Instead of discovering and running tests, read a file with one JSON-encoded test result dictionary per line, and report each line to test reporters as if we had just run that test.")
@@ -84,6 +84,8 @@ def __init__(self, *args, **kwargs):
self.runner_timeout = kwargs['options'].runner_timeout
self.revision = kwargs['options'].revision
self.server_timeout = kwargs['options'].server_timeout
+ self.shutdown_delay_for_connection_close = kwargs['options'].shutdown_delay_for_connection_close
+ self.shutdown_delay_for_outstanding_runners = kwargs['options'].shutdown_delay_for_outstanding_runners
self.test_queue = AsyncQueue()
self.checked_out = {} # Keyed on class path (module class).
@@ -381,6 +383,7 @@ def shutdown(self):
if self.runners_outstanding:
# Stop in 5 seconds if all the runners_outstanding don't come back by then.
- iol.add_timeout(time.time()+5, iol.stop)
+ iol.add_timeout(time.time()+self.shutdown_delay_for_outstanding_runners, iol.stop)
- iol.stop()
+ # Give tornado enough time to finish writing to all the clients, then shut down.
+ iol.add_timeout(time.time()+self.shutdown_delay_for_connection_close, iol.stop)

0 comments on commit fc2f9c7

Please sign in to comment.