On Sun, Aug 8, 2010 at 1:03 PM, Nick Arnett <nick.arn...@gmail.com> wrote:
> I'm having a problem that I can't figure out from reading the docs. I have > a loop that runs the same query every five minutes, to see if there is new > data to process. However, it doesn't return the new data the second and > subsequent times it loops. It's something like this: > > while 1: > data = Foo.objects.filter(not_analyzed=True) > if len(data): > for item in data: > do_analysis(item) > sleep(300) > > Even though I know there is new data added while it is sleeping, the query > doesn't return it. If I kill the process and re-start, it finds the new > data, so it smells like a caching problem... but I don't see anything in the > documentation that would suggest this. It shouldn't be the database query > cache (MySQL) because it should know the data has changed. > > I've tried adding "del data" at the bottom of the loop, but that didn't > help - thought maybe if I explicitly deleted the data, that would work. > > Any ideas what's going on or how to solve this? > > Probably you are seeing the effects of the default transaction isolation level on MySQL/InnoDB, which is "repeatable read". See http://groups.google.com/group/django-users/browse_thread/thread/e25cec400598c06dfor more explanation. Karen -- http://tracey.org/kmt/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.