I found a workaround to keep the connection available. Every 5 minutes, the desktop app fires an event wich calls this command:
db["_adapter"].connection.reset() This only works for a postgres database interface. I still couldn't find the cause for the connection irreversible closing I think the error appears only when the connection to the server is to other host, it does not seem to reproduce when connecting to the same machine, so maybe this is more a network issue than an application's. On 14 dic, 16:46, Alan Etkin <[email protected]> wrote: > Hi to all. > > I already asked to Massimo if there is a way to control by DAL methods > if a db connection went down and restart it: Seems that DAL should try > to re-establish the connection automatically. > > I am developing a desktop python app. with a gluon.shellfake > environment and any query is made within the same request object (it > is not reset) > > db transactions are executed normally with a postgres connection for > some minutes and after that, this error is raised on each db object > query command: > > Traceback (most recent call last): > File "/home/alan/gestionlibre_gui-hg/gui.py", line 215, in > OnLinkClicked > xml = action(link.Href) > File "/home/alan/gestionlibre_gui-hg/gui.py", line 397, in action > xml = gluon.template.render(filename=absolute_path, > path=config.TEMPLATES_FOLDER, context = action_data) > File "/home/alan/web2py-hg/gluon/template.py", line 916, in render > exec(code) in context > File "<string>", line 78, in <module> > File "/home/alan/web2py-hg/gluon/dal.py", line 6330, in select > return self.db._adapter.select(self.query,fields,attributes) > File "/home/alan/web2py-hg/gluon/dal.py", line 1282, in select > rows = response(sql) > File "/home/alan/web2py-hg/gluon/dal.py", line 1272, in response > self.execute(sql) > File "/home/alan/web2py-hg/gluon/dal.py", line 1359, in execute > return self.log_execute(*a, **b) > File "/home/alan/web2py-hg/gluon/dal.py", line 1353, in log_execute > ret = self.cursor.execute(*a, **b)psycopg2.OperationalError: el servidor > ha cerrado la conexión > inesperadamente > Probablemente se debe a que el servidor terminó de manera > anormal > antes o durante el procesamiento de la petición. > > How can I catch this connection issues to keep the application > database interface available? Is it a database engine/desktop app > related problem or is there something in DAL wich is not compatible > outside the web server environment? > > Here is my system configuration: > Python 2.6.5 > Linux O.S. > PostgreSQL 8.4 > web2py 1.99.3psycopg22.0.13

