Got help earlier with keeping my database connections alive between requests:
https://groups.google.com/forum/#!topic/web2py/QraWtFvlqf8
I put my databases in a module like this:
class Databases():
_td_db = None
@staticmethod
def getTDDB():
dbCreated = False
if Databases._td_db is None:
Databases._td_db = DAL('mysql://' + TD_DB_MYSQL_USER + ':' + TD_DB_MYSQL_PASS + '@' + TD_DB_URL + ':' + TD_DB_PORT + '/TD')
dbCreated = True
return Databases._td_db, dbCreated
After doing this I get very weird issues:
- Writing a value sometimes fails with lock timeout
- Writing a value and then reading a value sometimes doesn't give the written value back but instead what was written before (cache issue?)
I find nothing in web2py documentation about inbuilt caching, any idea what may cause these issues?
Going back to always recreating the DAL object seems to fix the issues.