Skip to content

Commit

Permalink
Analytics: python code coverage infrastructure
Browse files Browse the repository at this point in the history
- proper httpd shutdown
Partial-Bug: #1480463

Change-Id: I170bfaf7b5f11c5fc21cee6191bd27cdea8377fc
  • Loading branch information
tedghose committed Sep 15, 2015
1 parent a78bc27 commit 51fc7e2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
3 changes: 3 additions & 0 deletions library/python/pysandesh/sandesh_base.py
Expand Up @@ -126,6 +126,9 @@ def uninit(self):
def kill_httpd(self):
if self._gev_httpd:
try:
self._http_server.stop_http_server()
self._http_server = None
gevent.sleep(0)
self._gev_httpd.kill()
except Exception as e:
self._logger.debug(str(e))
Expand Down
18 changes: 13 additions & 5 deletions library/python/pysandesh/sandesh_http.py
Expand Up @@ -78,6 +78,7 @@ def __init__(self, sandesh, module, port, pkg_list):
self._jquery_collapse_storage_js_path = None
self._jquery_collapse_js_path = None
self._jquery_1_8_1_js_path = None
self._svr = None
try:
imp_pysandesh = __import__('pysandesh')
except ImportError:
Expand All @@ -95,18 +96,25 @@ def __init__(self, sandesh, module, port, pkg_list):

#end __init__

def stop_http_server(self):
if self._svr:
self._svr.shutdown()
self._svr = None
self._logger.error('Stopped http server')

def start_http_server(self):
try:
svr = make_server(SandeshHttp._HTTP_SERVER_IP, self._http_port,
self._http_app, SandeshWSGIServer)
self._svr = make_server(SandeshHttp._HTTP_SERVER_IP,
self._http_port,
self._http_app, SandeshWSGIServer)
except socket.error as e:
self._logger.error('Unable to open HTTP Port %d, %s' % (self._http_port, e))
sys.exit()
self._http_port = svr.server_port
self._http_port = self._svr.server_port
self._logger.error('Starting Introspect on HTTP Port %d' % self._http_port)
self._sandesh.record_port("http", self._http_port)
svr.allow_reuse_address = True
svr.serve_forever()
self._svr.allow_reuse_address = True
self._svr.serve_forever()

#end start_http_server

Expand Down

0 comments on commit 51fc7e2

Please sign in to comment.