Tried catching the exception when memcache is not available to switch to db
caching, but getting an excepting.
Should it be possible to catch this exception, ignore it and continue
running?
Thanks,
Adnan
try:
from gluon.contrib.memcache import MemcacheClient
memcache_servers = ['127.0.0.1:11211']
cache.memcache = MemcacheClient(request, memcache_servers)
cache.ram = cache.disk = cache.memcache
from gluon.contrib.memdb import MEMDB
session.connect(request,response,db=MEMDB(cache.memcache))
except:
sys.exc_clear()
session.connect(request, response, db=db)
pass
Traceback (most recent call last):
File "/Users/adnan/web2py24/gluon/main.py", line 557, in wsgibase
session._try_store_in_db(request, response)
File "/Users/adnan/web2py24/gluon/globals.py", line 739, in_try_store_in_db
record_id = table.insert(**dd)
File "/Users/adnan/web2py24/gluon/contrib/memdb.py", line 256, in insert
id = self._create_id()
File "/Users/adnan/web2py24/gluon/contrib/memdb.py", line 296, in_create_id
raise Exception('cannot set memcache')
Exception: cannot set memcache
Frames
File /Users/adnan/web2py24/gluon/main.py in wsgibase at line 557 code
arguments variables
File /Users/adnan/web2py24/gluon/globals.py in _try_store_in_db at line
739code arguments variables
File /Users/adnan/web2py24/gluon/contrib/memdb.py in insert at line 256code
arguments variables
File /Users/adnan/web2py24/gluon/contrib/memdb.py in _create_id at line
296code arguments variables
Function argument list
(self=<DALStorage {'client_ip': <gluon.contrib.memdb.F...luon.contrib.memdb.
Field object at 0x111d554d0>}>)
Code listing
291.
292.
293.
294.
295.
296.
297.
298.
299.
300.
id = self._tableobj.incr(shard_id)
if not id:
if self._tableobj.set(shard_id, '0'):
id = 0
else:
raise Exception('cannot set memcache')
return long(str(shard) + str(id))
def __str__(self):
return self._tablename
--