Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Changes to allow each HTTP request to be a seperate thread #139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 14, 2017

Conversation

jamessewell
Copy link
Contributor

@brian-brazil

This change allows each HTTP request to be served by a separate thread (I think!).

This came about because of a network issue, which was causing one Prometheus to keep a connection open - causing all other Proms to fail the exporter as they couldn't get a connection.

This is also consistent with the Go exporter behavior.

Cheers,
James

@@ -97,10 +97,13 @@ def log_message(self, format, *args):


def start_http_server(port, addr=''):
"""Starts a HTTP server for prometheus metrics as a daemon thread."""
"""Spawns each HTTPServer in a new thread to prevent blocking"""
Copy link
Contributor

Choose a reason for hiding this comment

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

This should still mention the daemon thread, as that's more important.

Copy link
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
Copy link
Contributor

Choose a reason for hiding this comment

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

extra space

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -12,8 +12,8 @@

from . import core
try:
Copy link
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
Contributor Author

Choose a reason for hiding this comment

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

Done

class ThreadingSimpleServer(ThreadingMixIn, HTTPServer):
pass
"""Starts a HTTP server for prometheus metrics in a new thread"""
"""Starts a HTTP server for prometheus metrics as a daemon thread."""
Copy link
Contributor

Choose a reason for hiding this comment

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

The daemon thread should be mentioned in start_http_server, as that's the primary docs the user will see.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, fixed

@brian-brazil brian-brazil merged commit ce5542b into prometheus:master Feb 14, 2017
@brian-brazil
Copy link
Contributor

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants