Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions prometheus_client/exposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@

from . import core
try:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also need to change Python3

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

from BaseHTTPServer import BaseHTTPRequestHandler
from BaseHTTPServer import HTTPServer
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
from SocketServer import ThreadingMixIn
from urllib2 import build_opener, Request, HTTPHandler
from urllib import quote_plus
from urlparse import parse_qs, urlparse
except ImportError:
# Python 3
unicode = str
from http.server import BaseHTTPRequestHandler
from http.server import HTTPServer
from http.server import BaseHTTPRequestHandler, HTTPServer
from socketserver import ThreadingMixIn
from urllib.request import build_opener, Request, HTTPHandler
from urllib.parse import quote_plus, parse_qs, urlparse

Expand Down Expand Up @@ -97,10 +97,12 @@ def log_message(self, format, *args):


def start_http_server(port, addr=''):
"""Starts a HTTP server for prometheus metrics as a daemon thread."""
"""Starts an HTTP server for prometheus metrics as a daemon thread"""
class ThreadingSimpleServer(ThreadingMixIn, HTTPServer):
pass
class PrometheusMetricsServer(threading.Thread):
def run(self):
httpd = HTTPServer((addr, port), MetricsHandler)
httpd = ThreadingSimpleServer((addr, port), MetricsHandler)
httpd.serve_forever()
t = PrometheusMetricsServer()
t.daemon = True
Expand Down