No. It is this line
db = DAL("mysql://root:[email protected]/mydb")
that connects and in a multi-threaded enviroment recycles connection
using a connection pool. I a connection from the pool is dead, it
tries reconnect. This happens in normal web2py apps.
In your code you are just running a script that happen to use the dal.
There is no connection pooling. If your connection dies in the sleep,
the next insert WILL NOT attept to reconnet.
Once more connections/reconnections are only done by DAL(...).
On Jan 13, 8:17 pm, hywang <[email protected]> wrote:
> I found it won't auto reconnect at this situation:
>
> from dal import DAL
> from dal import Field
> import time
> db = DAL("mysql://root:[email protected]/mydb")
>
> db.define_table("table1",
> Field("name"),
> migrate = False
> )
> db.table1.insert(name="jim")
> db.commit()
>
> # Close the connection from mysql server
> # error will be raised
> # the error is somthing like "connection lost during query"
> # and dal didn't reconnect at all
>
> time.sleep(10)
>
> # the connection is closed, and error occured when insert
> db.table1.insert(name="tom")
> db.commit()
> print "done"
>
> On 1月13日, 下午9时36分, Vasile Ermicioi <[email protected]> wrote:
>
>
>
>
>
>
>
> > if the connection is lost web2py tries to reconnect (5 times )