Il 23/10/2015 23:15, David Montgomery ha scritto:
Hi,

I am using the gevent loop with python bottle.

So every 120 seconds I load data from redis into a python hash.  For a sanity
check I save the data as a json string every 120 and can verify that the data is
updated due to the timer from the saved data I see on disk.

However, the worker has to use the updated hash to select items that might have
been updated from the data that was supposed to be updated from the reloaded
data.  However it is not.  For me to get updated data that works I have to do a
touch reload which defeats the purpose.  Below is my logic.  So how do I 
resolve?

Thanks


from uwsgidecorators import *
@rbtimer(120,target='workers')
  def load_redis(signum):
     updated_hash = redis.get('data')
    with open('/tmp/meta_post.json', 'w') as outfile:
             json.dump(updated_hash, outfile, indent=4, sort_keys=True)  <-THIS
WORKS

isn't updated_hash a local variable?


def foo(updated_hash){
     do stuff

@get('/hash/')
def hash():

       json_data = foo(updated_hash) <- THIS USES OLD DATA
       return json_data

Why aren't you simply reading from redis here? It would make things simpler. I can't think reading from redis is slower than "do stuff" with the hash.

--
Riccardo Magliocchetti
@rmistaken

http://menodizero.it
_______________________________________________
uWSGI mailing list
[email protected]
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi

Reply via email to