prometheus / prometheus/client_python
Exceptions not handled in server thread
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 4.4k
- Forks
- 876
- Merge medio
- 8 d 4 h
- PR fusionados (30 d)
- 1
Descripción
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)
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza en start_http_server() y revisa el issue #883 para conocer el comportamiento de retorno del hilo propuesto. Traza cómo los hilos del servidor HTTP y HTTPS gestionan las excepciones y, a continuación, determina cómo debe hacerse visible la excepción lanzada para el hilo principal; se considera terminado cuando ambos protocolos terminan el hilo del servidor sin finalizar el proceso silenciosamente.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- backend, networking
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 25/100