Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

spin loop in client/threadedclient.py causes cpu use in idle processes

Abierto
#142 0 comentarios 0 reacciones 0 asignados Ver en GitHub

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

bug

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

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de Lawouach/WebSocket-for-Python

Todos los issues de Lawouach/WebSocket-for-Python

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.