How to load a basic module from a cron job

458 views Asked by At

I am having trouble loading my GAE module.

My cron.yaml:

cron:
- description: call frontend instance to call module
  url: /callLoadAndProcess
  schedule: every day 01:00
  timezone: America/New_York

Then the relevant part of my app.yaml:

- url: /callLoadAndProcess
  script: callLoadAndProcess.application
  secure: always
  login: admin

Now my callLoadAndProcess.py:

import sys
import webapp2
import os
import urllib2
import logging
from google.appengine.api import modules

class callLoadAndProcess(webapp2.RequestHandler):
    def get(self):
        modules.start_module("loadandprocess","1")

application = webapp2.WSGIApplication([('/callLoadAndProcess', callLoadAndProcess)],debug=True)

For my module, I have a loadandprocess.yaml, which is:

application: [application name]
module: loadandprocess
version: 1
runtime: python27
instance_class: B4_1G
basic_scaling:
  max_instances: 1

handlers:
- url: /.*
  script: loadAndProcess.application
  login: admin

And finally, loadAndProcess.py is the script I want run as a backend module:

class loadAndProcess(webapp2.RequestHandler):
    def get(self):
            #DO STUFF

application = webapp2.WSGIApplication([('/loadAndProcess', loadAndProcess)],debug=True)

In my development server, when I try to run the cron job via the admin page, I get the following error:

line 138, in _CheckAsyncResult
raise mapped_error()
InvalidVersionError

I feel I set it up correctly... and the version numbers match.. did I miss something? Thanks!

1

There are 1 answers

1
Nahuel On

To run the app locally, specify both .yaml files to dev_appserver.py:

dev_appserver.py -A your-app-id application.yaml worker.yaml