Commit f5011a4
committed
[Bugfix] Fix PrometheusStatsLogger crash on re-instantiation and non-daemon thread
Two bugs in observability.py:
1. When _metric_mappings is already populated (e.g. multi-engine or
hot-reload), __init__ returns early without initializing instance
attributes (is_running, thread, config, etc.). Any subsequent call
to shutdown() or __del__() raises AttributeError. Fix: always
initialize core instance attributes before the early-return guard.
2. The update_stats_loop thread is not created as a daemon thread.
If shutdown() is never explicitly called, this thread prevents the
Python process from exiting cleanly. Fix: set daemon=True, and
guard shutdown() against thread being None.
Signed-off-by: supermario_leo <leo.stack@outlook.com>1 parent e6ca062 commit f5011a4
1 file changed
Lines changed: 12 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
69 | 76 | | |
70 | 77 | | |
71 | 78 | | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | 79 | | |
76 | 80 | | |
77 | 81 | | |
| |||
97 | 101 | | |
98 | 102 | | |
99 | 103 | | |
100 | | - | |
| 104 | + | |
| 105 | + | |
101 | 106 | | |
102 | | - | |
| 107 | + | |
103 | 108 | | |
104 | 109 | | |
105 | 110 | | |
| |||
190 | 195 | | |
191 | 196 | | |
192 | 197 | | |
193 | | - | |
| 198 | + | |
| 199 | + | |
194 | 200 | | |
195 | 201 | | |
196 | 202 | | |
| |||
0 commit comments