EMM
EMM

Reputation: 1812

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?

Upvotes: 3

Views: 341

Answers (2)

tesdal
tesdal

Reputation: 2459

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.

Upvotes: 4

Daniel Roseman
Daniel Roseman

Reputation: 599470

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

Upvotes: 2

Related Questions