Ensure there's always an http server object

It's possible for a test to complete before python gets around to
actually starting the webapp run thread.  Make sure that the
object referenced in the stop method is always instantiated to
avoid "AttributeError: 'WebApp' object has no attribute 'server'"
errors.

Also, mark the webapp thread as daemon on general principle.

Change-Id: I9b4c0c20a98d5429c299748178e31baf8b6912d9
This commit is contained in:
James E. Blair 2014-03-11 15:35:00 -07:00
parent 5e79b4686e
commit f31b3436eb
1 changed files with 3 additions and 2 deletions

View File

@ -26,10 +26,11 @@ class WebApp(threading.Thread):
threading.Thread.__init__(self)
self.scheduler = scheduler
self.port = port
def run(self):
self.daemon = True
self.server = httpserver.serve(self.app, host='0.0.0.0',
port=self.port, start_loop=False)
def run(self):
self.server.serve_forever()
def stop(self):