benoitc / benoitc/socketpool

Phantom time?

Aperta
#31 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Python
Stelle
167
Fork
33
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

I frequently see the following error in logs when socketpool is used from inside a thread (via threading module). I'm unaware if the time module or socketpool are inherently un-thread-safe, nor can I tell if there are any negative effects of the issue. It is quite bizarre though:

The exception:

```
Exception in thread Thread-1 (most likely raised during interpreter shutdown):
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
File "/opt/webapps/filmbot/venv/local/lib/python2.7/site-packages/socketpool/backend_thread.py", line 50, in run
: 'NoneType' object has no attribute 'sleep'
```

The related code:

``` python
def run(self):
self.running = True
while True:
time.sleep(self.delay)
self.pool.murder_connections()
```

where somehow time has become None.

I see at the top of the backend_thread module that the author assigns a reference to time.sleep, yet never uses the reference and instead still accesses sleep from the time import. Not sure what the utility of that is, or if it's an omission, etc.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Inizia leggendo socketpool/backend_thread.py, in particolare run e il riferimento a time.sleep a livello di modulo, quindi riproduci il traceback dell’arresto del thread descritto nell’issue. Determina perché time diventa None e se il riferimento salvato a sleep è destinato a impedirlo; il lavoro è completato quando l’eccezione durante l’arresto e il suo impatto sono compresi e affrontati.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
networking
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
48/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.