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.
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.