I have a script that sits in a loop, doing occasional queries, something like

while 1:
  wait.for.some.event()
  object=get.some.django.db.object()
  do.something.with(object)
  transaction.commit_unless_managed()

The last line is required so the script will see updates to the
database from other processes. If there's no event for a long time,
the database wait timeout is exceeded, and the script aborts with a
"mysql sever has gone away" message. This is expected.

What is surprising to me is that the error consistently happens during
commit_unless_managed(). It's been waiting for an event for 8+ hours,
finally gets one, appears to do a db query, and then aborts during
commit because the connection is gone.

What's going on here? Is this a caching issue? Django satisfies the
query w/o touching the db, then aborts when updating with the db?

If this is the case, I suspect the commit should be just after the wait.

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

Reply via email to