← Volver al índice de módulos

app_python3

This module is a port of the 'app_python' module to Python 3. It is based on the work of Maxim Sobolev.
⚙️ Scripting e Integración Kamailio 6.1 10 parámetros 2 funciones

Descripción general

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")').

Documentación oficial: https://www.kamailio.org/docs/modules/stable/modules/app_python3.html
Código fuente: https://github.com/kamailio/kamailio/tree/master/src/modules/app_python3

Parámetros de configuración

ParámetroTipoDescripció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()

Funciones exportadas

python_exec(method [, args])

4.1. python_exec(method [, args])

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.

Autores y contribuidores

Maxim SobolevAnthony Alba

Copyright © 2010 Maxim Sobolev

Módulos relacionados

app_lua app_perl app_python app_python3s app_ruby app_ruby_proc async evapi