You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add a RqlCursorEmpty exception to the python driver #3974
Just to make sure I understand the issue:
You mentioned in the other thread
Unfortunately, if the user doesn't catch this, it interacts poorly with Tornado, which assumes the StopIteration means that the coroutine has finished.
Is that a special meaning of StopIteration in Tornado? What happens with other exceptions that the user doesn't catch? Would they also terminate the coroutine?
@danielmewes, yes, you can see in the source here, the implementation of _make_coroutine_wrapper treats a raise StopIteration() the same as a raise gen.Return(None). Other exceptions will be put into the returned future and will be re-raised when those futures are yielded.
@v3ss0n (Edit: removed possible wrong answer). I'm actually not sure if you can catch the StopIteration at the moment (pinging @Tryneus ).
You might want to wait until this is fixed.
(you can track threads by clicking the "Subscribe" button on the right by the way)
Both cursor.next() and cursor.fetch_next() take a wait optarg to specify how long to wait before timing out (after which a RqlTimeoutError exception is raised). This optarg defaults to True, which will wait indefinitely. cursor.fetch_next() only exists on the TornadoCursor implementation.
@v3ss0n, thanks for your interest, let us know if you have any problems or suggestions after trying it out!
Activity
danielmewes commentedon Mar 24, 2015
Just to make sure I understand the issue:
You mentioned in the other thread
Is that a special meaning of
StopIterationin Tornado? What happens with other exceptions that the user doesn't catch? Would they also terminate the coroutine?Tryneus commentedon Mar 24, 2015
@danielmewes, yes, you can see in the source here, the implementation of
_make_coroutine_wrappertreats araise StopIteration()the same as araise gen.Return(None). Other exceptions will be put into the returned future and will be re-raised when those futures areyielded.danielmewes commentedon Mar 24, 2015
Got it, thanks!
danielmewes commentedon Mar 24, 2015
Your proposed change makes total sense then. 👍
v3ss0n commentedon Mar 25, 2015
Leaving a message here to track this.
I am going to test rethinkdb + Tornado this weekend.
So for now , user need to catch the
StopIterationright?danielmewes commentedon Mar 25, 2015
@v3ss0n (Edit: removed possible wrong answer). I'm actually not sure if you can catch the
StopIterationat the moment (pinging @Tryneus ).You might want to wait until this is fixed.
(you can track threads by clicking the "Subscribe" button on the right by the way)
Tryneus commentedon Mar 25, 2015
This has been approved and merged to
nextin commit 2171061, and cherry-picked intov2.0.xin commit c08b40d. Review was 2742. Will be in release 2.0.The proper way to iterate over a TornadoCursor object is now:
or
Both
cursor.next()andcursor.fetch_next()take awaitoptarg to specify how long to wait before timing out (after which aRqlTimeoutErrorexception is raised). This optarg defaults toTrue, which will wait indefinitely.cursor.fetch_next()only exists on the TornadoCursor implementation.@v3ss0n, thanks for your interest, let us know if you have any problems or suggestions after trying it out!
v3ss0n commentedon Apr 2, 2015
ah i forgot that. trying now