spin loop in client/threadedclient.py causes cpu use in idle processes
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 1/5
- Tiempo estimado
- Menos de una hora
- Aptitud para principiantes
- 45/100
- Tipo de issue
- Documentación
- Claridad
- Bien especificado
- Estado de actividad
- Estancado
- Stack tecnológico
- python
- Área
- networking
Línea de trabajo
Open client/threadedclient.py and read WebSocketClient.run_forever(), then review the history reference to issue #109 for the timeout rationale. Done means the existing timeout and SIGINT behavior are clearly documented in a comment without changing the loop.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
In client.threadedclient, WebSocketClient has a method run_forever(). The body of the code is:
while not self.terminated:
self._th.join(timeout=0.1)
top was showing bunches of processes that weren't doing anything, which I eventually traced to this spin loop. Of course, my first thought was WTF? because there is no apparent need for a timeout here. I managed to trace the code through the github history and found a reference to issue #109
I suggest a comment something like this in this function:
# signals and threads are not friends in python. Without the timeout, you can't
# interrupt this function with SIGINT. The timeout ensures that we return to the
# main thread periodically, so a pending SIGINT can be processed. If this causes
# unreasonable CPU usage in your application, just override this method to not
# have a timeout, and don't try to interrupt it with SIGINT.
It is not clear to me that this is a problem for most users, but it was for me. I first noticed because the fans in my computer were speeding up even though my application wasn't doing anything. (I have lots of processes on standby.)
- Lenguaje dominante
- Python
- Estrellas
- 1.1k
- Forks
- 285
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
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.
Más de Lawouach/WebSocket-for-Python
-
Dificultad 3/5 1-2 días Aptitud para principiantes 45/100
Lawouach/WebSocket-for-Python#300 ·
-
question
Lawouach/WebSocket-for-Python#297 · 2 comentarios · 1 asignado ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 20/100
Lawouach/WebSocket-for-Python#296 ·
-
Lawouach/WebSocket-for-Python#280 · 1 comentario · 1 asignado ·
-
Setup new CI Abierto
Lawouach/WebSocket-for-Python#275 · 1 asignado ·
Todos los issues de Lawouach/WebSocket-for-Python
Issues similares
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
stephrobert/dsoxlab#238 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
sublimehq/package_control#1780 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
nwg-piotr/nwg-displays#145 ·