here is my directory structure:
Worker/
worker.py
worker.yaml
SharedCode/
sharedMoudle1.py
sharedMoudle2.py
...
in the worker.py
, I want to include code from the shared folder. obviously in my local computer, it works since I have the Directory.
How Do I configure the worker.yaml
to deploy the SharedCode
directory together with sharedCode
??
here is my worker yaml
runtime: python27
api_version: 1
threadsafe: true
vm: true
service: worker
env_variables:
PYTHON_ENV: lab
network:
instance_tag: testing
name: olympus-dev
handlers:
- url: /.*
script: worker.app
login: admin
ps not using the the sharedCode
, the worker works fine
Your need to convert your directories to python modules (by adding an __init__.py
file), and then place the .yaml
file in your project root directory. Your final directory structure should look similar to this:
worker.yaml
worker/
__init__.py
worker.py
sharedcode/
__init__.py
sharedmodule1.py
sharedmodule2.py
Then edit the handlers directive in your yaml, as follows:
handlers:
- url: /.*
script: worker.worker.app
login: admin
Here's an example on how to import code from the shared module:
from sharedcode.sharedmodule.py import *
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.