을 통과하는 동안 메모리 부족 I이 종류 RawEmailModel 및 업데이트 카운터의 모든 엔티티를 반복 할 코드를 다음앱 엔진 : 테이블
def update_emails(cursor=None, stats = {}):
BATCH_SIZE = 100
if not cursor:
# Start of the job
pass
next_cursor = cursor
more = True
try:
while more:
rawEmails, next_cursor, more = RawEmailModel.query().fetch_page(BATCH_SIZE, start_cursor=next_cursor)
ndb.get_context().clear_cache()
for rawEmail in rawEmails:
try:
stats[rawEmail.userId] += 1
except Exception:
stats[rawEmail.userId] = 0
logging.debug(stats)
logging.debug("Done counting")
except Exception as e:
logging.error(e)
내가 읽어 내가 무엇을 기반으로 NDB 캐시를 삭제하고 내가 루프의 상단에있는 캐시를 지우고 계속 때 여전히 메모리가 부족 해요 왜
20:21:55.240 {u'104211720960924551911': 45622, u'105605183894399744988': 0, u'114651439835375426353': 2, u'112308898027744263560': 667, u'112185522275060884315': 804}
F 20:22:01.389 Exceeded soft private memory limit of 128 MB with 153 MB after servicing 14 requests total
W 20:22:01.390 While handling this request, the process that handled this request was found to be using too much memory and was terminated. This is likely to cause a new process to be used for the next request to your application. If you see this message frequently, you may have a memory leak in your application.
을하지 않습니다 https://stackoverflow.com/a/12108891/2448805 그러나, 나는 아직도 내가 메모리가 부족 해요 말하는 오류를 얻을? 감사!
RawEmailModel.query()를 while 루프 외부로 옮기는 것이 좋습니다. –
하지만 모든 엔티티 (~ 100k)를 반복하면서 한 번에 100 개의 이메일을 가져 오는 것이므로 while 루프 내부에 있어야합니다. –