Hi Luke,
Yes. I could not find the root cause of the issue but i managed a
workaround. I got it working by using before_first_request hook
in flask. By loading the keys there i can use more than one worker
without encountering the issue.
Here is the sample app:
import os, sys
from flask import Flask, request, Response, jsonify, g, url_for,
make_response, session import riak
app = Flask(__name__)
riak_client = riak.RiakClient(host='127.0.0.1', pb_port=10017,
protocol='pbc')
content_keys = []
@app.before_first_request
def _run_on_start():
print 'Content bucket'
content_bucket =riak_client.bucket_type('content').bucket('content')
print 'cache content keys'
#content_keys = content_bucket.get_keys()
for keys in content_bucket.stream_keys():
for key in keys:
content_keys.append(key)
@app.route("/")
def myapp():
print 'get bucket'
user_bucket = riak_client.bucket_type('user_type').bucket('users')
print 'Total content: %s' % len(content_keys)
print '####################### get user info from bucket'
user_info = user_bucket.get('auser')
return '', 200
if __name__ == '__main__':
app.run(
host="0.0.0.0",debug=False,
port=int("5000")
)
:tele
On Mon, 6 Jul 2015 08:49:59 -0700
Luke Bakken <[email protected]> wrote:
> Question at the bottom, thanks.
>
> On Sat, Jun 20, 2015 at 1:10 PM, tele <[email protected]> wrote:
> > Hi All,
> >
> > This is going to be a long post but it explains exactly how to
> > reproduce the issue.
>
> Code listing:
>
> > print 'cache content keys'
> > content_keys = []
> > #content_keys = content_bucket.get_keys()
> > for keys in content_bucket.stream_keys():
> > for key in keys:
> > content_keys.append(key)
>
> Do you run into the same issue if you use get_keys() rather than
> stream_keys() ?
>
> --
> Luke Bakken
> Engineer
> [email protected]
_______________________________________________
riak-users mailing list
[email protected]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com