import timefrom pydal import DAL, Field
db = DAL('postgres:://web2py:web2py@localhost:5433/test_w2p')db.define_table('thing',Field('name'))db.thing.insert(name='Chair')db.commit()
while True: print db(db.thing).count() time.sleep(60)
psycopg2.OperationalError: terminating connection due to administrator command
SSL connection has been closed unexpectedly
....
try: print db(db.thing).count() except: db._adapter.reconnect() print db(db.thing).count()
--
-- mail from:GoogleGroups "web2py-developers" mailing list
make speech: web2py-d...@googlegroups.com
unsubscribe: web2py-develop...@googlegroups.com
details : http://groups.google.com/group/web2py-developers
the project: http://code.google.com/p/web2py/
official : http://www.web2py.com/
---
You received this message because you are subscribed to the Google Groups "web2py-developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py-develop...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi Massimo,
I've no http requests at all,i forgot to mantion that it's a python script based on pydal.
It' a feature pydal should have but normally not necessary in web2py (maybe for the scheduler?)
In this case, a db io is better than a failure.
while True: try: print db(db.thing).count() db.commit() except Exception as e: try:
db._adapter.close(action=None) except: pass db._adapter.reconnect() print 'Sleeping' time.sleep(60)
The idea I've in mind, and partially implemented, is to let any command (without really knowing what really they are) to try transparently to reconnect to the server. I don't get why you don't want .select, .update and so on to reconnect.
There is no harm in trying to reestablish the connection if the command that fails is the first of a newly started transaction.Its common to leave an IDLE connection for hours, even days, open and thinking that one can start a transaction and push a command through it right away when needed.To keep a command queue is up to the user of pydal IMHO. Something that is out of the scope of pydal itself.What I'm trying to say is that one can hide the most common cause of IOError, which is an IDLE connection TIMEDOUT.
From niphload's example, running the select again after the first disconnection is useless because all rows are already in res. After the second disconnection no commands are in the cmd-queue, as a result no other queries are executed; the re-connection will come during the update. Do you agree ?
--
Don't know what's the actual status (i.e. if you think the close() changes made some improvements), but current pyDAL seems to have serious issues with pg8000.
I'll have a look asap@niphold how do you think the change on close() affects pg8000 ?