8000 Comment on memory leak #340 · prometheus/client_python@51de8ba · GitHub
[go: up one dir, main page]

Skip to content

Commit 51de8ba

Browse files
committed
Comment on memory leak #340
Signed-off-by: Sebastian Brandt <sebastian.brandt@friday.de>
1 parent ef36e1c commit 51de8ba

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

prometheus_client/exposition.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@ def factory(cls, registry):
173173

174174
class _ThreadingSimpleServer(ThreadingMixIn, HTTPServer):
175175
"""Thread per request HTTP server."""
176+
# Make worker threads "fire and forget". Beginning with Python 3.7 this
177+
# prevents a memory leak because ``ThreadingMixIn`` starts to gather all
178+
# non-daemon threads in a list in order to join on them at server close.
179+
# Enabling daemon threads virtually makes ``_ThreadingSimpleServer`` the
180+
# same as Python 3.7's ``ThreadingHTTPServer``.
176181
daemon_threads = True
177182

178183

0 commit comments

Comments
 (0)
0