diff options
Diffstat (limited to 'python')
-rw-r--r-- | python/gras/GRAS_HierBlock.i | 6 | ||||
-rw-r--r-- | python/gras/stats/__init__.py | 17 |
2 files changed, 18 insertions, 5 deletions
diff --git a/python/gras/GRAS_HierBlock.i b/python/gras/GRAS_HierBlock.i index 3c4e75e..1d2ba6e 100644 --- a/python/gras/GRAS_HierBlock.i +++ b/python/gras/GRAS_HierBlock.i @@ -95,6 +95,12 @@ struct TopBlockPython : TopBlock PyTSPhondler phil; return TopBlock::wait(timeout); } + + std::string get_stats_xml(void) + { + PyTSPhondler phil; + return TopBlock::get_stats_xml(); + } }; struct HierBlockPython : HierBlock diff --git a/python/gras/stats/__init__.py b/python/gras/stats/__init__.py index 2ed52ea..596616d 100644 --- a/python/gras/stats/__init__.py +++ b/python/gras/stats/__init__.py @@ -29,8 +29,15 @@ class MyHandler(BaseHTTPServer.BaseHTTPRequestHandler): if not path: path = 'main.html' s.wfile.write(open(os.path.join(__path__, path)).read()) -def http_server(args, get_stats_xml): - get_stats_registry[0] = get_stats_xml - server_class = BaseHTTPServer.HTTPServer - httpd = server_class(args, MyHandler) - return httpd +import select + +class http_server(object): + def __init__(self, args, get_stats_xml): + get_stats_registry[0] = get_stats_xml + server_class = BaseHTTPServer.HTTPServer + self._httpd = server_class(args, MyHandler) + + def serve_forever(self): + while True: + try: self._httpd.serve_forever() + except select.error: pass |