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:
parent
5e79b4686e
commit
f31b3436eb
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue