0

My staging GAE app throws the below err,

File "/base/data/home/apps/foo156801/worker:20170301t222555.399535951340506041/lib/MySQLdb/__init__.py", line 19, in <module>
import _mysql
ImportError: dynamic module does not define init function (init_mysql)

which was exactly same as this. According to the answer given on that link, I have changed my app.yaml MysqlDb version and the local mysqldb version to points to a same version. But no luck. Still I got the above error.

app.yaml

libraries:
 - name: jinja2
   version: latest
 - name: MySQLdb
   version: "1.2.5"

requirements.txt

Flask-API==0.6.9
MySQL-python==1.2.5
Community
  • 1
  • 1
Avinash Raj
  • 172,303
  • 28
  • 230
  • 274
  • No, I made the requirements.txt file for to installing third party packages into `lib` folder. ie, `pip install -r requirements.txt -t lib` – Avinash Raj Mar 02 '17 at 04:58
  • Ah, I see, never mind :) – Dan Cornilescu Mar 02 '17 at 05:05
  • If I remove mysqldb package from my lib folder with the builtin mysqldb entry exists, it shows `No module named MySQLdb`. And if I remove the builtin entry and the mysqldb package still exists on my lib folder then it shows the above error. – Avinash Raj Mar 02 '17 at 05:10
  • @Dan But queries on default module works perfectly file.. But the db queries on worker module or service throws the above exception. I have `/api/users/list` endpoint on my default module which gets all the users from the database.. It works just fine.. – Avinash Raj Mar 03 '17 at 07:13
  • But on the another api, I have set the default module to call a task which actually exists on worker module, say `/send-email` in worker.py . In this handler I added a query to search in one of my tables . This causes error. – Avinash Raj Mar 03 '17 at 07:16
  • 2 modules? You only show 1 `.yaml` file... – Dan Cornilescu Mar 03 '17 at 07:21
  • oh, wait.. I need to add mysqldb in worker module also (worker.yaml), right?. – Avinash Raj Mar 03 '17 at 07:22
  • finally it works...... – Avinash Raj Mar 03 '17 at 07:35

1 Answers1

1

The multiple services/modules of an application do not share any code, see Service isolation.

Because of this requesting runtime-provided libraries or vendoring in 3rd party libraries needs to be replicated in each service/module.

Symlinks can also be used for vendoring in 3rd party libs in DRY spirit, see Sharing entities between App Engine modules.

Community
  • 1
  • 1
Dan Cornilescu
  • 39,470
  • 12
  • 57
  • 97
  • So it won't share also the environment variables? Like in the default module , i set `foo: bar` in app.yaml. Can I access that env variable in worker.py `os.environ.get('foo', 'None')`. Is this would return None? – Avinash Raj Mar 03 '17 at 07:50
  • Yep, `worker.yaml` needs its instructions as well. This may help: http://stackoverflow.com/questions/33307128/do-i-need-to-copy-skip-files-across-multiple-yaml-files/33308640#33308640 – Dan Cornilescu Mar 03 '17 at 13:09
  • Fundamentally the modules are completely isolated from the code prospective, the worker module could be a flex env module, written in another language, with a totally different style of configurations. – Dan Cornilescu Mar 03 '17 at 13:11
  • ya, I already tested worker module completely written in php lang. – Avinash Raj Mar 03 '17 at 13:12