Can't get a module to start via a cron job

290 views
Skip to first unread message

Adrian

unread,
Jan 6, 2014, 9:05:09 AM1/6/14
to google-a...@googlegroups.com
I am having trouble with getting a cron job to start a module... I made a post to Stackoverflow that has the problem... I was going to repost here, but everything is formatted on Stackoverflow. 


Does anyone have any ideas? Thanks

Vinny P

unread,
Jan 6, 2014, 8:00:01 PM1/6/14
to google-a...@googlegroups.com
On Mon, Jan 6, 2014 at 8:05 AM, Adrian <adrianj...@gmail.com> wrote:
I am having trouble with getting a cron job to start a module... I made a post to Stackoverflow that has the problem.


Can you supply the full traceback from the error? 


-----------------
-Vinny P
Technology & Media Advisor
Chicago, IL

App Engine Code Samples: http://www.learntogoogleit.com

Adrian

unread,
Jan 6, 2014, 8:03:25 PM1/6/14
to google-a...@googlegroups.com
Thanks Vinny -- here is the full traceback:

Traceback (most recent call last):
  File "/home/adrian/google_appengine/lib/webapp2-2.5.1/webapp2.py", line 1536, in __call__
    rv = self.handle_exception(request, response, e)
  File "/home/adrian/google_appengine/lib/webapp2-2.5.1/webapp2.py", line 1530, in __call__
    rv = self.router.dispatch(request, response)
  File "/home/adrian/google_appengine/lib/webapp2-2.5.1/webapp2.py", line 1278, in default_dispatcher
    return route.handler_adapter(request, response)
  File "/home/adrian/google_appengine/lib/webapp2-2.5.1/webapp2.py", line 1102, in __call__
    return handler.dispatch()
  File "/home/adrian/google_appengine/lib/webapp2-2.5.1/webapp2.py", line 572, in dispatch
    return self.handle_exception(e, self.app.debug)
  File "/home/adrian/google_appengine/lib/webapp2-2.5.1/webapp2.py", line 570, in dispatch
    return method(*args, **kwargs)
  File "/home/adrian/arapphost/callLoadAndProcess.py", line 10, in get
    modules.start_module("loadandprocess","1")
  File "/home/adrian/google_appengine/google/appengine/api/modules/modules.py", line 385, in start_module
    rpc.get_result()
  File "/home/adrian/google_appengine/google/appengine/api/apiproxy_stub_map.py", line 612, in get_result
    return self.__get_result_hook(self)
  File "/home/adrian/google_appengine/google/appengine/api/modules/modules.py", line 403, in _ResultHook
    _CheckAsyncResult(rpc, mapped_errors)
  File "/home/adrian/google_appengine/google/appengine/api/modules/modules.py", line 138, in _CheckAsyncResult
    raise mapped_error()
InvalidVersionError

Vinny P

unread,
Jan 7, 2014, 2:47:39 AM1/7/14
to google-a...@googlegroups.com
On Mon, Jan 6, 2014 at 7:03 PM, Adrian <adrianj...@gmail.com> wrote:
  File "/home/adrian/arapphost/callLoadAndProcess.py", line 10, in get
    modules.start_module("loadandprocess","1")
  File "/home/adrian/google_appengine/google/appengine/api/modules/modules.py", line 385, in start_module
    rpc.get_result()


The traceback claims that the module and version you're referring to doesn't exist. Try to debug the problem by:

1. Sometimes modules throw up unusual errors when versions are expressed as pure numbers instead of a mix of letters and numbers. In loadandprocess.yaml, change version: 1 to version: one. Remember to update callLoadAndProcess.py with the correct version (the start_module call).

2. You can use get_modules() and get_versions(module=___) in the modules package to enumerate all the modules and all the versions of a given module that App Engine recognizes within your application. App Engine may be recording the module under a different name or version. 

Adrian

unread,
Jan 7, 2014, 3:19:12 PM1/7/14
to google-a...@googlegroups.com
Thank you for the suggestions... this is odd... my directory has a "loadandprocess.yaml" module, with the following text:

application: [my app name]
module: loadandprocess
version
: one
runtime
: python27
api_version
: 1
threadsafe
: true
instance_class
: B4_1G
basic_scaling
:
  max_instances
: 1
 
handlers
:
- url: /.*
  script
: loadAndProcess.application
  login
: admin

But whenever I call 
logging.info(modules.get_modules())

It only recognizes my default application:

INFO     2014-01-07 20:15:50,482 callLoadAndProcess.py:10] ['default']

Aside from just having the [module name].yaml file in the directory with my default app.yaml file, do I need to do anything else to get the dev_server to recognize the additional module?

Thanks!

alex

unread,
Jan 7, 2014, 7:15:40 PM1/7/14
to google-a...@googlegroups.com
> Aside from just having the [module name].yaml file in the directory with my default app.yaml file, do I need to do anything else to get the dev_server to recognize the additional module?

Make sure you supply all *.yaml files to dev_appserver in cmdline args, e.g.:

dev_appserver.py app.yaml module1.yaml module2.yaml dispatch.yaml

Execute dev_appserver.py -h for more details.

Vinny P

unread,
Jan 7, 2014, 9:40:36 PM1/7/14
to google-a...@googlegroups.com
+1 to Alex's post.

You can also try running Google's modules example: https://github.com/GoogleCloudPlatform/appengine-modules-helloworld-python to make sure there's nothing wrong with your dev environment.

Adrian

unread,
Jan 8, 2014, 9:08:50 AM1/8/14
to google-a...@googlegroups.com
Hey Alex,

Thanks for the reply -- when I load in all of my modules (app.yaml and loadandprocess.yaml), I now have this error when I go to the cron tab on the devserver admin page:

Error loading cron.yaml:



Traceback (most recent call last):

 
File "/home/adrian/google_appengine/google/appengine/tools/devappserver2/admin/cron_handler.py", line 42, in get
    values
['cronjobs'] = self._get_cron_jobs()
 
File "/home/adrian/google_appengine/google/appengine/tools/devappserver2/admin/cron_handler.py", line 48, in _get_cron_jobs
    cron_info
= self._parse_cron_yaml()
 
File "/home/adrian/google_appengine/google/appengine/tools/devappserver2/admin/cron_handler.py", line 80, in _parse_cron_yaml
    cron_info
= croninfo.LoadSingleCron(f)
 
File "/home/adrian/google_appengine/google/appengine/api/croninfo.py", line 151, in LoadSingleCron
    listener
.Parse(cron_info)
 
File "/home/adrian/google_appengine/google/appengine/api/yaml_listener.py", line 226, in Parse
   
self._HandleEvents(self._GenerateEventParameters(stream, loader_class))
 
File "/home/adrian/google_appengine/google/appengine/api/yaml_listener.py", line 177, in _HandleEvents
   
raise yaml_errors.EventError(e, event_object)
EventError: Unable to assign value 'America/New_York' to attribute 'timezone':
timezone
'America/New_York' is unknown


Any ideas? Thanks.. 

Adrian

unread,
Jan 8, 2014, 9:17:12 AM1/8/14
to google-a...@googlegroups.com
This is the part of the cron.yaml file it is getting upset with (line 5):

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

alex

unread,
Jan 8, 2014, 9:31:55 AM1/8/14
to google-a...@googlegroups.com
Are you sure you have pytz installed on your system?

Try this from cmd line: python -c "import pytz; print pytz.timezone('America/New_York')"
Should print out "America/New_York". If it doesn't, something's wrong with pytz. Note that it's not included in App Engine SDK. Usually it's installed as a system package.

Anyway, aside from timezone, whether it works or not, try commenting it out and see if you get all the modules running:

1. Go to http://localhost:8000 - it should display all of your modules.
2. Try executing "curl http://localhost:8080/callLoadAndProcess" and see if it works. It should. If it doesn't, you'll probably need to tweak your dispatch.yaml file.

hope this helps!


--
You received this message because you are subscribed to a topic in the Google Groups "Google App Engine" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-appengine/_YIp716sTlw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-appengi...@googlegroups.com.
To post to this group, send email to google-a...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-appengine.
For more options, visit https://groups.google.com/groups/opt_out.

alex

unread,
Jan 8, 2014, 9:35:46 AM1/8/14
to google-a...@googlegroups.com
> If it doesn't, something's wrong with pytz. Note that it's not included in App Engine SDK. Usually it's installed as a system package.

Anyway, if there's no such package as "pytz" you could try installing it by running "sudo pip install pytz" or "sudo easy_install pytz".

Adrian

unread,
Jan 8, 2014, 9:52:51 AM1/8/14
to google-a...@googlegroups.com
Hey Alex,

Thanks for the reply -- it's very strange.. pytz is installed as I can import it, but I can't load America/New_York...  I just tried uninstalling and reinstalling pytz and that didn't work either.. 

$ python -c "import pytz; print pytz.timezone('America/New_York')"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "pytz/__init__.py", line 173, in timezone
    raise UnknownTimeZoneError(zone)
pytz.UnknownTimeZoneError: 'America/New_York'


I installed gae-pytz... I'm wondering if that is somehow interfering with pytz?

Adrian

unread,
Jan 8, 2014, 10:50:18 AM1/8/14
to google-a...@googlegroups.com
Okay... I can load cron.yaml now... turns out if I launch my dev_server from the folder that the app is in, it doesn't load pytz property, but if I load dev_server from my home directory and just address my yaml files via [myappname]/app.yaml and [myappname]/loadandprocess.yaml it works.. not sure why that is, but at least that problem is fixed. 

Thanks for the suggestions!
Reply all
Reply to author
Forward
0 new messages