I have a standalone python script (i.e. not part of a web app) that
makes use of the ORM. I call djago.setup(), make some queries, then
call a function that can take 8 hours or more to run. When the
function returns I want to make more queries, but they fail with 'Lost
connection to MySQL server during query'. My DB wait_timeout is set to
8 hours and if the function returns in less than 8 hours I don't get
the error, so I thought I understood what was going on.

But then I read about CONN_MAX_AGE which we do not set. If that is not
set it should default to 0, which should mean that it gets a new
connection for each request so we should not get the Lost connection
message. Does that not work when using djago.setup()?

Further reading I saw said to call close_old_connections() or
connection.close() before calling the long running function. What is
the difference between these 2 and is one a better practice than the
other?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY4tBWRsLBW5URC%3DNcBgmuFhMaSxTO_y1rGf8HUD80B3Rw%40mail.gmail.com.

Reply via email to