prometheus / prometheus/client_python
Exceptions not handled in server thread
Personne n'a encore pris cette issue.
- Langage dominant
- Python
- Étoiles
- 4.4k
- Forks
- 876
- Merge moyen
- 8 j 4 h
- PR mergées (30 j)
- 1
Description
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)
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par start_http_server() et examinez l’issue #883 concernant le comportement de retour du thread proposé. Suivez la manière dont les threads du serveur HTTP et HTTPS gèrent les exceptions, puis déterminez comment l’exception levée doit devenir visible pour le thread principal ; le travail est terminé lorsque les deux protocoles arrêtent le thread du serveur sans terminer silencieusement le processus.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- python
- Domaine
- backend, networking
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 25/100