No. It is this line

db =  DAL("mysql://root:passw...@127.0.0.1/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 <why00...@163.com> 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:passw...@127.0.0.1/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 <elff...@gmail.com> wrote:
>
>
>
>
>
>
>
> > if the connection is lost web2py tries to reconnect (5 times  )

Reply via email to