prometheus / prometheus/client_python
Exceptions not handled in server thread
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 4.4k
- Fork
- 876
- Merge trung bình
- 8 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 1
Mô tả
We are occasionally getting an ssl.SSLEOFError when using the prometheus client with HTTPS (as of the new version 0.19.0). That error is raised in the server thread and because it is not handled there, the entire process dies:
Traceback (most recent call last):
File "/usr/lib/python3.10/wsgiref/handlers.py", line 138, in run
self.finish_response()
File "/usr/lib/python3.10/wsgiref/handlers.py", line 184, in finish_response
self.write(data)
File "/usr/lib/python3.10/wsgiref/handlers.py", line 288, in write
self.send_headers()
File "/usr/lib/python3.10/wsgiref/handlers.py", line 346, in send_headers
self.send_preamble()
File "/usr/lib/python3.10/wsgiref/handlers.py", line 268, in send_preamble
self._write(
File "/usr/lib/python3.10/wsgiref/handlers.py", line 467, in _write
result = self.stdout.write(data)
File "/usr/lib/python3.10/socketserver.py", line 826, in write
self._sock.sendall(b)
File "/usr/lib/python3.10/ssl.py", line 1237, in sendall
v = self.send(byte_view[count:])
File "/usr/lib/python3.10/ssl.py", line 1206, in send
return self._sslobj.write(data)
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:2426)
Traceback (most recent call last):
File "/usr/lib/python3.10/wsgiref/handlers.py", line 138, in run
self.finish_response()
File "/usr/lib/python3.10/wsgiref/handlers.py", line 184, in finish_response
self.write(data)
File "/usr/lib/python3.10/wsgiref/handlers.py", line 288, in write
self.send_headers()
File "/usr/lib/python3.10/wsgiref/handlers.py", line 346, in send_headers
self.send_preamble()
File "/usr/lib/python3.10/wsgiref/handlers.py", line 268, in send_preamble
self._write(
File "/usr/lib/python3.10/wsgiref/handlers.py", line 467, in _write
result = self.stdout.write(data)
File "/usr/lib/python3.10/socketserver.py", line 826, in write
self._sock.sendall(b)
File "/usr/lib/python3.10/ssl.py", line 1237, in sendall
v = self.send(byte_view[count:])
File "/usr/lib/python3.10/ssl.py", line 1206, in send
return self._sslobj.write(data)
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:2426)
I verified that this exception is not raised within start_http_server() so it must be happening in the server thread.
The goal would be that the exception raised in the server thread causes the server thread to terminate and the main thread has some means to get to the exception raised in the server thread. The solution would need to work for both HTTP and HTTPS.
There seem to be different techniques on how that can be achieved:
This would probably require that the start_http_server() function returns the thread object (see issue #883)
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu tại start_http_server() và xem xét issue #883 về hành vi trả về của thread được đề xuất. Theo dõi cách các thread máy chủ HTTP và HTTPS xử lý ngoại lệ, sau đó xác định cách ngoại lệ được phát sinh phải trở nên hiển thị đối với thread chính; hoàn thành có nghĩa là cả hai giao thức đều kết thúc thread máy chủ mà không âm thầm kết thúc tiến trình.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- backend, networking
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 25/100