Recently I found a wired problem in my application, something like
this: I have a long time deamon program, it'll be an infinite loop,
just like:

engine = create_engine('...')
conn = engine.connect()
while True:
    for row in select:
        update
    sleep(xxx)

In the loop, I create conn at first, and then reuse it in the loop. If
there is data in database, it'll fetch all matched records and update
the flag, then do the next loop. So if there is no matched records,
it'll just sleep and do nothing.

The problem is, because I used the shared connection object, so if
there is no matched records for a while, and even I changed the
database to make some records, it'll not fetch the records at all. And
if I restart the program it'll get them at the first time, then if I
changed the database, it'll not fetch the records again. But If I put
the conn creation in the loop, it seems everything is ok.

And if I tried to use strategy='threadlocal', and get the conn like:
conn = engine.contextual_connect(), even I put this line in the loop,
the problem is still existed.

So I don't know if someone else has faced the same problem like me? I
don't know if I need to recreate connection every time in the loop?

-- 
I like python!
UliPad <<The Python Editor>>: http://code.google.com/p/ulipad/
UliWeb <<simple web framework>>: http://code.google.com/p/uliweb/
My Blog: http://hi.baidu.com/limodou

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to