From 51de8badc929b0e8d5fd27957fa9debb523f2dee Mon Sep 17 00:00:00 2001 From: Sebastian Brandt Date: Tue, 11 Dec 2018 09:26:22 +0100 Subject: [PATCH] Comment on memory leak #340 Signed-off-by: Sebastian Brandt --- prometheus_client/exposition.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/prometheus_client/exposition.py b/prometheus_client/exposition.py index cc3161e5..61996618 100644 --- a/prometheus_client/exposition.py +++ b/prometheus_client/exposition.py @@ -173,6 +173,11 @@ def factory(cls, registry): class _ThreadingSimpleServer(ThreadingMixIn, HTTPServer): """Thread per request HTTP server.""" + # Make worker threads "fire and forget". Beginning with Python 3.7 this + # prevents a memory leak because ``ThreadingMixIn`` starts to gather all + # non-daemon threads in a list in order to join on them at server close. + # Enabling daemon threads virtually makes ``_ThreadingSimpleServer`` the + # same as Python 3.7's ``ThreadingHTTPServer``. daemon_threads = True