So I've gone back and forth on this again and again. It looks like cache.ram being process bound (so even though I only have one web2py instance, it's running across multiple wsgi processes?) was the problem. The issue is, I'm having similar issues (in a very different location) using cache.disk. I though maybe it might be better to use memcache instead, but I get a keyerror when trying to use memcache to cache the DAL, since my key regularly exceeds 250 chars (relatively small query, but lists every field it looks like)
On Dec 21, 5:54 pm, Tim Alexander <[email protected]> wrote: > It occurs to me, I'm using uwsgi. I'm assuming cache.ram is per process, > meaning that if my Ajax side and xmlrpc side are not on the same process, > this will completely not work properly. I'll try flipping over to cache.disk > tomorrow morning to verify. > On Dec 21, 2010 5:20 PM, "Dragonfyre13" <[email protected]> wrote: > > > At least I think the subject seems to define the behavior. > > > I have a function that exposes as an XMLRPC service. It puts something > > in a DB, and then polls to see if there is a response to it from > > another system talking to that same DB. (yes I realize that polling a > > DB is a "bad thing" but necessary for various reasons in this case) > > > The difficulty is, there's an xmlrpc side, and an ajax side. The ajax > > side is a longpoll (simulated server side push) with a loop like this: > > > while endtime > datetime.datetime.now(): > > # This keeps finding a cached value, even when it's cleared > > by > > # another request. > > #for k in cache.ram.storage.keys(): > > #logging.debug(k,v) > > #if k.find("next_action.ccid=" + str(ccid)) != -1: > > # logging.debug(str(ccid) + "found cached value") > > actionrow = localdb(localdb.next_action.ccid == ccid).select( > > cache=(cache.ram,600)).first() > > if actionrow and len(actionrow) and actionrow.action_str != > > None and \ > > actionrow.return_str == None: > > return dict(action_xml=actionrow.action_str, > > ccid=ccid) > > time.sleep(.5) > > > The XMLRPC side is much the same. ccid is a unique key for the > > "conversation" for both of them to use. The action string is where the > > XMLRPC side pushes information, and return_str is data that is handed > > back after the ajax longpoll fulfills the action string's needs. > > > My problem in all of this is the comments above. Even though when I do > > an update on the XMLRPC side, I clear cache for this select statement > > (via setting timeout to 0 for that select statement in cache) it still > > maintains the value pulled from cache in the ajax request above. So I > > don't pull out the actual value in the DB until cache expires in this > > function, even though I've cleared the cache via setting timeout to 0 > > in the other function: > > localdb(localdb.next_action.ccid == ccid).select(cache=(cache.ram, 0)) > > > Any ideas? For now, I really don't know what I'm looking at for an > > issue or resolution, but even a "yep, makes a copy when your request > > object is created" would work if someone knows. Or "you're an idiot, > > do it like this" would be even better!

