spin loop in client/threadedclient.py causes cpu use in idle processes
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 1/5
- Tempo stimato
- Meno di un'ora
- Idoneità per principianti
- 45/100
- Tipo di issue
- Documentazione
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Ferma
- Stack tecnologico
- python
- Ambito
- networking
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.)
- Lingua principale
- Python
- Stelle
- 1.1k
- Fork
- 285
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Lawouach/WebSocket-for-Python
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
Lawouach/WebSocket-for-Python#300 ·
-
question
Lawouach/WebSocket-for-Python#297 · 2 commenti · 1 assegnatario ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 20/100
Lawouach/WebSocket-for-Python#296 ·
-
Lawouach/WebSocket-for-Python#280 · 1 commento · 1 assegnatario ·
-
Setup new CI Aperta
Lawouach/WebSocket-for-Python#275 · 1 assegnatario ·
Tutte le issue di Lawouach/WebSocket-for-Python
Issue simili
-
area: harness bug status: needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
Human-Agent-Society/reef#625 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 80/100
learningequality/kolibri#15351 · 2 commenti ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Name consistency Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
eellak/triplestore#65 · 1 commento ·