I figured out that I needed to do a
alerts = Alert.all().filter('expires >= ', datetime.datetime.now
()).fetch(1000)

Apparently it is faster to do a fetch() than iterate over the values.

On Apr 30, 7:28 pm, tayknight <[email protected]> wrote:
> Data is returned in development almost instantly. In production, the
> error is returned after about 4 seconds. I get the datastore error
> long before 30 seconds.
>
> On Apr 29, 9:08 am, Liang Zhao <[email protected]> wrote:
>
> > Each request can only run 30 seconds in server side,
>
> > but in development server, there is no limitation on it...
>
> > On Wed, Apr 29, 2009 at 11:56 PM, tayknight <[email protected]> wrote:
>
> > > And, I should add, this works perfecty (and quickly) from the
> > > development server's datastore.
>
> > > On Apr 29, 8:31 am, tayknight <[email protected]> wrote:
> > >> I have a problem. I'm getting datastore timeouts when doing reads. The
> > >> code finished about 5% of the time. The code looks like:
>
> > >> alerts = Alert.all().filter('expires >= ', datetime.datetime.now())
> > >> # ge active alerts
> > >> for alert in alerts:
> > >>   #get the db.Keys from the ListProperty
> > >>   zones = ZoneMaster.get(alert.zones)
> > >>   for zone in zones:
> > >>     if zone:
> > >>       #get the users for this zone
> > >>       if zone.siteusers:
> > >>         us = SiteUser.get(zone.siteusers)
> > >>           for u in us:
> > >>             if u:
> > >>               self.response.out.write(u.name + '<br />')
>
> > >> The Model looks like:
> > >> class Alert(db.Model):
> > >>   effective = db.DateTimeProperty()
> > >>   expires = db.DateTimeProperty()
> > >>   zones = db.ListProperty(db.Key)
>
> > >> class ZoneMaster(db.Model):
> > >>   siteusers = db.ListProperty(db.Key)
>
> > >> class SiteUser(db.Model):
> > >>   name = db.StringProperty()
> > >>   zone = db.ReferenceProperty(ZoneMaster)
>
> > >> This code is repeatably timing out with a "Timeout: datastore timeout:
> > >> operation took too long." error.
> > >> I'm not doing any writes. All the reads are by key (that come from a
> > >> ListProperty). Why would this be timing out?
>
> > >> Thanks.
>
> > --
>
> > Cheers!
>
> > Liang Zhao- Hide quoted text -
>
> > - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to