two possible issues:
a) you're not using session.forget(response). To avoid concurrent 
modification of the same value in session, by default requests insisting on 
the same session will be serialized. Whenever you use ajax and you don't 
use session, use session.forget(response)
b) cache.ram tries to avoid concurrent modifications of the same key: this 
means that both reads and writes are blocked if something else is 
reading/writing the value... this is infinitesimally less noticeable than 
a).

On Monday, May 2, 2016 at 6:16:27 PM UTC+2, Alfonso Serra wrote:
>
> Im trying to use cache.ram for a progress bar and i have this problem.
>
> I have 2 controllers, 
> progress: that changes cache.ram each second 
> getprog: that retrieves the cache.ram value whenever i like.
>
> import json as Json
>
> #convert a variable into a json response
> def json(var):
>     response.headers['Content-Type'] = "application/json; charset=utf-8"
>     return Json.dumps(var, ensure_ascii=False)
>
> #get progress status
> def getprog():
>     msg = cache.ram('message', lambda: None, None)
>     return json({"msg": msg})
>
> #start a process that updates the progress
> def progress():
>     from time import sleep
>     # when a form is submitted, change progress each second
>     if request.ajax:
>         for i in range(10):
>             cache.ram('message', lambda: i, time_expire=0)
>             print "main:", i
>             sleep(1)
>         return "done"
>     else:
>         cache.ram('message', lambda: -1, time_expire=0)
>     return locals()
>
> When progress is triggered it begins to change cache.ram("message") each 
> second
>
> If i visit getprog when progress is working, on localhost works well, i 
> get the current value, but on pythonanywhere, getprog returns a response 
> when progress is finished, not while at it.
>
> Is there any parameter or way to tell cache.ram to return the current 
> value without waiting for other controllers to finish?
>
> Thanks.
>
> PD: i have tried without time.sleep, but i get the same result, cant ask 
> for the progress until the main controller (the one that updates cache.ram 
> finishes)
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to