Hi, after upgrade to the latest pypi version (py4web 1.20220412.1, pydal 20220213.2) the connection leak with DAL is still present and with my ClosingDAL I started receiving this error:
Traceback (most recent call last):
File "/home/py4web/.local/lib/python3.8/site-packages/py4web/core.py", line 935, in wrapper
ret = func(*func_args, **func_kwargs)
File "/home/py4web/.local/lib/python3.8/site-packages/py4web/core.py", line 920, in wrapper
raise context["exception"]
File "/home/py4web/.local/lib/python3.8/site-packages/py4web/core.py", line 916, in wrapper
call(fixture.on_success, context)
File "/home/py4web/.local/lib/python3.8/site-packages/py4web/core.py", line 882, in call
return f(context)
File "/home/py4web/apps/.../modules/....py", line 205, in on_success
self.close()
File "/home/py4web/.local/lib/python3.8/site-packages/pydal/base.py", line 830, in close
if self._db_uid in THREAD_LOCAL._pydal_db_instances_:
AttributeError: '_thread._local' object has no attribute '_pydal_db_instances_'
so, now I have to ignore the error (another workaround):
class ClosingDAL(pydal.DAL, Fixture):
reconnect_on_request = True
def on_request(self, context):
if self.reconnect_on_request:
self._adapter.reconnect()
threadsafevariable.ThreadSafeVariable.restore(ICECUBE)
def __close_silently(self):
try:
self.close()
except Exception as e:
print(f"[DAL] closing error {e}")
def on_error(self, context):
self.rollback()
self.__close_silently()
def on_success(self, context):
self.commit()
self.__close_silently()
David