Python SDK 0.7.2 and stale=false
I think I have detected a tweak in Python SDK 0.7.2, even I'm not completely sure. Running version 2.0.0 community edition (build-722)
Executing this code for the first time, with empty bucket and updated views:
from couchbase import Couchbase # connect to a couchbase server cb = Couchbase('184.108.40.206:8091', username='Administrator', password='t0ur52r3m3mb3R') default_bucket = cb['default'] default_bucket['key1'] = 'value1' default_bucket['key2'] = 'value2' default_bucket['key3'] = 'value3' print "First query" rows = default_bucket.view("_design/testing/_view/all", stale="false") for row in rows: #expected keys: key1, key2, key3 print row default_bucket['key4'] = 'value4' print "Second query" rows = default_bucket.view("_design/testing/_view/all", stale="false") for row in rows: #expected keys: key1, key2, key3, key4 print row
Is outputing this (no results at all!):
Kara:tours2remember apolion$ python test3.py
Without returning any results.
I supposed that the first view call with stale="false" should return the right keys (key1, key2, key3), as the index should be updated before retuning any results. But it is not retuning anything.
Also the second view call does not return anything, which is kind of confusing. If stale=false is not supported. The client should return the right data in the second call of the view.
More details: Second time I execute the script, with no additional actions on couchbase admin web interface (no view call), I get all the expected results both in the First and the Second queries.
Am I missing something? Or did I just missunderstood the action of stale=false in this case?
== UPDATE ==
Just discovered that adding an sleep(0.5) call right before calling the view for the first time makes the whole thing work properly and I get the expected results.
I cannot rely on this sleep call to retrieve the right data. Is it possible to implement a Observer pattern by passing a callback as an argument to the view call?