Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Migrating GAE app from python 2.5 to 2.7

I am trying to migrate my app and everything worked fine until I changed in app.yaml from threadsafe: false to threadsafe: true.

The error I was receiving was:

threadsafe cannot be enabled with CGI handler: a/b/xyz.app

After some googling I found:

Only scripts in the top-level directory work as handlers, so if you have any in subdirectories, they'll need to be moved, and the script reference changed accordingly:

- url: /whatever
# This doesn't work ...
# script: lib/some_library/handler.app
# ... this does work
script: handler.app

Is there any workaround for this(if above research is valid), as I don't want to change my project hirarchy?

like image 985
EMM Avatar asked Jan 20 '26 23:01

EMM


2 Answers

You can have your handlers anywhere as long as it's a valid python import path.

My app.yaml is full of entries like

- url: /_ah/queue/deferred
  script: google.appengine.ext.deferred.application
  login: admin

The folders need __init__.py in them to make them work as modules, but you can usually replace any / with .

Alternatively do as Daniel suggest, and note that you'll probably have to mangle the sys.path first to include lib dir and then import handler.

like image 168
tesdal Avatar answered Jan 23 '26 21:01

tesdal


Put a main file in the top-level directory and import all your handlers there, then reference them via that file

like image 38
Daniel Roseman Avatar answered Jan 23 '26 20:01

Daniel Roseman