No subject


Sun Nov 12 08:01:13 CET 2006


Applications'), I kind of understand about thread initialization,
and acquiring and releasing the lock while executing python statements.

My question is, do I need to wrap every single grouping of Py*()
function calls within an acquire/release lock pair, or are there
special calls that I should target.  I'm asking this, because the
Py*() calls are dispersed throughout a few files and I'm not sure
how to go about coding these so that I can have threads in my
Python code work.

A sample of the main init code follows (Borland C++Builder 3):

    Py_Initialize();

    PySys_SetArgv(_argc, _argv); // let Python see Borlandish args to Cntlr

    // Add our own script directory to the module search path
    if (PyRun_SimpleString("import sys"))
        return;
    cmd = String("sys.path.insert(0, '") +
                 AUTOLOAD_SCRIPT_DIR +
                 "')" ;
    if (PyRun_SimpleString(cmd.c_str()))
        return;

    // Autoload our primitives that are defined in Python.
    // Exec, not import, these so that they
    // are available in main namespace.
    cmd = String("execfile('") + 
        AUTOLOAD_SCRIPT_DIR + "\\\\" +
        AUTOLOAD_PRIMS_FILE + "')";
    if (PyRun_SimpleString(cmd.c_str()))
        return;

... then, in the destructor for this class, we only have
    the following statement...

    Py_Finalize();



More information about the Python-list mailing list