I have a GAE project written in Python. I made a cron to execute a batch operation. But it hit a soft private memory limit of F1 instance, which is 124MB after a few iterations. Could anyone help me to write this code more efficiently, hopefully within 124MB. len(people) should be less than 500.
def cron():
q = Account.all().filter('role =', 1)
people = [e for e in q]
for p in people:
s = Schedule.available(p)
m = ScheduleMapper(s).as_dict()
memcache.set('key_for_%s' % p.key(), m)
This is dev server and I don't want to upgrade my instance class. Plus, I want to avoid using third party libraries, such as numpy and pandas.
I added a garbage collection in the last line of for loop. But it doesn't seem to be working.
del s
m.clear()
import gc
gc.collect()