Re: [google-appengine] Exceeded soft memory limit using key()

2012-02-29 Thread Andreas
1. why dont you query for keys_only instead of the whole entity when you need 
the key only anyway?
Model.all(keys_only=True)  ... i guess query = ModelA.all().all() is a typo.

2. how many entities are you feching in total? of course if you continue 
fetching 1000 entities and you have 10k entities the entityList will be pretty 
big and then you will hit the memory limit.

3. instead of the forloop it would be better if you would do:
entityList.append(queryResult)... if you query keys only like i did 
above
otherwise it would be entityList.append([str(e.key()) for e in 
queryResult]) but that does not make sense if you need keys only.



On Feb 28, 2012, at 10:50 PM, H.N. wrote:

> Hi everyone,
> 
> My program has a problem look like memory leak (log: Exceeded soft
> memory limit). I find it is the result of instance methods key() of
> Model Class. Algorithm as below:
> 
> 
> def post(self):
>"""/queue_task/get_key
>Get all entity key of ModelA
>"""
>entityList = []
>cursor = self.request.get('cursor', '')
> 
>query = ModelA.all().all()
>if cursor:
>query.with_cursor(cursor)
>queryResult = query.fetch(1000)
>for entity in queryResult:
>entityList.append(entity.key().__str__())
> 
># save entityList into datastore
> 
>taskqueue.add(url='/queue_task/get_key',
>  params={'cursor': query.cursor()},
>  queue_name='task',
>  target='backendA')
> 
> The usage memory will increase (all task run in one backend instance)
> and exceeded soft memory limit finally. If I replace entity.key() with
> some variable or string, it is work successfully. What happens in this
> code or key() of Model Class??
> 
> Thanks
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Google App Engine" group.
> To post to this group, send email to google-appengine@googlegroups.com.
> To unsubscribe from this group, send email to 
> google-appengine+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/google-appengine?hl=en.
> 

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



[google-appengine] Exceeded soft memory limit using key()

2012-02-29 Thread H.N.
Hi everyone,

My program has a problem look like memory leak (log: Exceeded soft
memory limit). I find it is the result of instance methods key() of
Model Class. Algorithm as below:


def post(self):
"""/queue_task/get_key
Get all entity key of ModelA
"""
entityList = []
cursor = self.request.get('cursor', '')

query = ModelA.all().all()
if cursor:
query.with_cursor(cursor)
queryResult = query.fetch(1000)
for entity in queryResult:
entityList.append(entity.key().__str__())

# save entityList into datastore

taskqueue.add(url='/queue_task/get_key',
  params={'cursor': query.cursor()},
  queue_name='task',
  target='backendA')

The usage memory will increase (all task run in one backend instance)
and exceeded soft memory limit finally. If I replace entity.key() with
some variable or string, it is work successfully. What happens in this
code or key() of Model Class??

Thanks

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