Multi Threading embedded python



Hello,

I am embedding a python script in a C++ application. The script can be called simultaneously from multiple threads.

What is the correct way to implement this situation:

1) Have unique python interpreter instantiations ( Py_Initialize() ) for each thread.

2) Have one python interpreter, and implement a lock on it so it can't be called simultaneously by multiple threads?

Thanks
  Amit
.



Relevant Pages

  • Re: dbcopy over secure/encrypted line
    ... Why not write a simple python script that has two database ... connections. ... then create multiple threads and do a ... You can do this over an SSH tunnel. ...
    (comp.databases.informix)
  • Re: mod_python and threads
    ... If one is on Win32 or using worker mode for Apache, ... The data for each Python interpreter is distinct, ... then multiple threads can be operating within the ... context of the same Python interpreter instance. ...
    (comp.lang.python)
  • import random module
    ... When I import the random module at the python interpreter, ... when I put the same code in a python script: ... AttributeError: 'module" object has no attribut 'randint' ... I run scripts at the command line everyday so there must be something ...
    (comp.lang.python)
  • Re: run python from a tcl/tk GUI
    ... > Donal K. Fellows schrieb: ... >> The executable to use is the python interpreter, ... >> exec python myScript.py ... up python.exe and use the python script as the argument. ...
    (comp.lang.tcl)