If a callback throws an exception, Consumer.wait() hangs.

Offen
#147 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

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

Rechercherichtung

Beginne in couchdbkit/consumer/sync.py beim im Traceback gezeigten wait loop und reproduziere das Problem mit Consumer.wait(cb) gegen einen kontinuierlichen _changes-Feed und einem Callback, der ValueError auslöst. Verfolge die Bereinigung des with restkit-Wrappers und bestätige, dass die Callback-Ausnahme wait nicht mehr hängen lässt, während der Stream offen bleibt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

>>> import couchdbkit
>>> db = couchdbkit.Server("http://localhost:5984")["temp"]
>>> c = couchdbkit.Consumer(db)
>>> def cb(*args):
...     print "In callback"
...     raise ValueError
... 
>>> c.wait(cb)
In callback

Nothing is printed after this point, and the process hangs. It continues to read from _changes, though it does nothing.

Control-C reveals where it's stuck:

^CTraceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/daniel/temp/src/couchdbkit/couchdbkit/consumer/__init__.py", line 103, in wait
    return self._consumer.wait(cb, **params)
  File "/home/daniel/temp/src/couchdbkit/couchdbkit/consumer/sync.py", line 56, in wait
    break
  File "/home/daniel/temp/lib/python2.6/site-packages/restkit/wrappers.py", line 161, in __exit__
    self.close()
  File "/home/daniel/temp/lib/python2.6/site-packages/restkit/wrappers.py", line 169, in close
    self.body.read()
  File "/usr/lib/python2.6/io.py", line 940, in read
    return self._read_unlocked(n)
  File "/usr/lib/python2.6/io.py", line 955, in _read_unlocked
    chunk = self.raw.read()
  File "/usr/lib/python2.6/io.py", line 589, in read
    return self.readall()
  File "/usr/lib/python2.6/io.py", line 599, in readall
    data = self.read(DEFAULT_BUFFER_SIZE)
  File "/usr/lib/python2.6/io.py", line 591, in read
    n = self.readinto(b)
  File "/home/daniel/temp/lib/python2.6/site-packages/http_parser/reader.py", line 60, in readinto
    recved = self.http_stream.stream.readinto(buf)
  File "/home/daniel/temp/lib/python2.6/site-packages/http_parser/reader.py", line 150, in readinto
    return _readinto(self._sock, b)
  File "/home/daniel/temp/lib/python2.6/site-packages/http_parser/reader.py", line 25, in _readinto
    buf = sock.recv(l)
KeyboardInterrupt

As far as I can tell, __ exit __ is called because of the 'with restkit wrapper:' block in sync.py. It then attempts to read the remainder of the stream, which it can't do because continuous changes never ends.

The above console output was produced after installing 'git://github.com/benoitc/couchdbkit.git#egg=couchdbkit' into a clean virtualenv, though I get the same problem with couchdbkit 0.6.3 on python2.7 on another box.

Thanks,
Daniel

Vorherrschende Sprache
Python
Sterne
261
Forks
90
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus benoitc/couchdbkit

Alle Issues in benoitc/couchdbkit

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

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