By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,167 Members | 1,591 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,167 IT Pros & Developers. It's quick & easy.

problem with embbed boost.python in multi-interpreter andmulti-thread HELP please

P: n/a
I wrote a program embbed boost.python, each thread running a sub-interpreter, i made a module implement by boost.python, and i wish this module imported in each sub-interpreter, i find that the module could initialize only once, otherwise the boost.python will throw a exception said that something already registered; second conversion method ignored.

So I try another way, initialize and import the module in one interpreter such as the main interpreter, and I hope to import the module in any sub-interpreter, because I found the python document said:
"Extension modules are shared between (sub-)interpreters as follows: the first time a particular extension is imported, it is initialized normally, and a (shallow) copy of its module's dictionary is squirreled away. When the same extension is imported by another (sub-)interpreter, a new module is initialized and filled with the contents of this copy; the extension's init function is not called. "
but when i try this way i found that the program throw an exception:ImportError: No module named mym, (mym is the module name). This happens even i wrote the module in Python/C API without boost.python.

Could somebody tell me why this happened or how to deal with it, thanks for any suggestion.

Donnie Leen
Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a
All right, I found the answer in boost.python test example embedding.cpp,
not to call initmodulename() in every sub-interpreter, just call
PyImport_AppendInittab("modulename", initmodulename) before call to
Py_Initialize(), this will add the module to the interpreter's builtin
modules, then I can call "import modulenmame" in each sub-interpeter.

Donnie Leen
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.