This module is a port of the 'app_python' module to Python 3. It is based on the work of Maxim Sobolev. This module cannot be loaded together with 'app_python' as global symbols have not been renamed. To ease transition, the functions, KEMI exports, and RPC commands have the same names as 'app_python', which also means the two modules cannot coexist. This module allows executing Python scripts from the config file, exporting functions to access the SIP message from Python. For some basic examples of Python scripts that can be used with this module, look at the files inside the source tree located at 'modules/app_python3/python_examples/'. Note: if symbols exported to KEMI (module or function names) conflict with Python's reserved keywords, use the 'getattr()' function or the '__dict__' attribute for 'KSR' (e.g., 'KSR.__dict__["async"].task_route("myroute")').
| Parámetro | Tipo | Descripción |
|---|---|---|
| load | string | 3.2. script_name (string) 3.3. mod_init_function (string) 3.4. child_init_method (string) 3.5. threads_mode (int) |
| script_name | string | 3.3. mod_init_function (string) 3.4. child_init_method (string) 3.5. threads_mode (int) |
| mod_init_function | string | 3.4. child_init_method (string) 3.5. threads_mode (int) |
| child_init_method | string | 3.5. threads_mode (int) |
| threads_mode | int | 3.1. load (string) |
| load | string | The path to the file with Python code to be executed from configuration file. |
| script_name | string | This is same as "load" parameter, kept for backward compatibility with the older versions of the module. |
| mod_init_function | string | The Python function to be executed by this module when it is initialized by Kamailio. |
| child_init_method | string | The Python function to be executed by this module when a new worker process (child) is initialized by Kamailio. |
| threads_mode | int | Control how locking for Python interpreter threads in done. If set to 1, use Py_BLOCK_THREADS/Py_UNBLOCK_THREADS (new mode added for v6.0.x). If set to 0, use PyGILState_Ensure()/PyGILState_Release() |
4.1. python_exec(method [, args])
Execute the Python function with the name given by the parameter 'method'. Optionally can be provided a second string with parameters to be passed to the Python function.
Copyright © 2010 Maxim Sobolev