benoitc / benoitc/socketpool

Phantom time?

Offen
#31 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Python
Sterne
167
Forks
33
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

Beginne mit dem Lesen von socketpool/backend_thread.py, insbesondere von run und der Referenz auf time.sleep auf Modulebene, und reproduziere anschließend den im Issue beschriebenen Traceback beim Herunterfahren des Threads. Ermittle, warum time zu None wird und ob die gespeicherte sleep-Referenz dies verhindern soll; fertig ist die Untersuchung, wenn die Ausnahme beim Herunterfahren und ihre Auswirkungen verstanden und behoben sind.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
networking
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
48/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.