mercredi 6 février 2019

The Apache module is called in same thear?

Have a Apache module using with C-Python. In the Apache module i declared:

ap_hook_handler(
    custom_function,
    NULL,
    NULL,
    APR_HOOK_REALLY_FIRST
);

And, in the custom function initialize python library:

int custom_function(request_rec *r)
{
    Py_Initialize();

    //Somecode here

    return DECLINED;
}

My question is: The python initializer is called in httpd multithread? or the custom_function is multi-called in same thread?, need call Py_Initialize only once time? or by each custom_function() execution?

bool corePythonInitialized = false;

int custom_function(request_rec *r)
{
    if(!corePythonInitialized)
    {
        Py_Initialize();
        corePythonInitialized = true;
    }

    //Somecode here

    return DECLINED;
}

Aucun commentaire:

Enregistrer un commentaire