Hi Daniel and kamailio contributors,
I have submitted a PR for app_python3 here:
https://github.com/kamailio/kamailio/pull/1447.
It is very rough, but would appreciate your feedback.
Notes:
1. Almost a verbatim port of app_python; just changing obvious
semantics. String->Unicode is practically the only large change. No
change to symbol names and export functions so the two modules cannot
coexist. (Don't loadmodule "app_python.so" and loadmodule
"app_python3.so)
2. Module initialization semantics in Py3 have changed: add the top
level modules to the inittab before calling Py_Initialize(). I have
done this for KSR and Router. I.e. PyImport_AppendInittab() is called
for Router and KSR *before* Py_Initialize()
3. Makefile looks for a python3 binary (PYTHON3 in the Makefile) to
get include paths and link libraries. Here is an example compile line
for IUS Python 3.6 on CentOS 7 (no native Python3 from RHEL)
## default: needs to find python3 and python3-config
## needs to find both python3.6 and python3.6-config
make -C src/ PYTHON3=python3.6 SKIP_MODULES="${SKIP_MODULES}"
quiet=verbose module_group_py="app_python3" group_include=py
every-module
4. The semantics for GIL and thread management are too different for
one-to-one replacements. I have therefore decided to comment out all
threading calls. Fortunately, kamailio does not used threads at the
moment. This is more complicated than it seems: even with Py2+thread
management: there would be deadlocks if kamailio->python2
script->Cython extension with threads(e.g. grpcio). For an MVP it
would be best to get it in without thread management.
5. It should backport to 5.1.
6. Tested locally, with a routing scripting making many python_exec() calls
Thank you.
Anthony Alba