maybe something like this?

try:
    your script that defines a db = DAL(...)
finally:
    db.close()


On Saturday, 5 May 2018 19:53:48 UTC-5, Brendan Barnwell wrote:
>
> I think this question is more about PyDAL than web2py.  What I'm doing is 
> using the web2py shell to call functions and do stuff within a web2py app, 
> but without actually running the web server.  Everything happens within a 
> Python shell.  In this environment, database transactions are not 
> automatically committed.  That is fine as far as it goes, but the problem 
> is that, as far as I can tell, if the interpreter exits with open DB 
> transactions, those transactions remain hanging in a "zombie" state.  This 
> can cause future DB operations to hang (if, for instance, an zombie 
> transaction was trying to update a row).
>
> Is there any way to guarantee that at *interpreter exit* all DB 
> transactions will be closed (presumably aborted) and nothing will be left 
> hanging?  Is there a reason that PyDAL does not include, for instance, an 
> atexit handler to ensure this?  It is very annoying to be doing stuff in 
> the shell and then have the DB frozen because I ended the interpreter 
> session and forgot to close the connection.  It seems like a natural safety 
> maneuver to automatically close down all connections at interpreter exit, 
> but it appears PyDAL doesn't do this.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to