miconda left a comment (kamailio/kamailio#4153)
Found some time to setup a small testing instance, stripping further from you sample configs attached for app_python3s. Just sending OPTIONS didn't result in a blocking state, so it is not about kamailio's inside code for executing the Python script, but by sending INVITEs, it got blocked, so it should be some impact of the functions used for processing INVITEs.
Maybe @space88man can figure out more if he is more familiar with the matter, I will also try to dig in.
For now, I introduced a new module parameter `threads_mode` which defaults to `0` and used the (old) code before the pr/patch https://github.com/kamailio/kamailio/pull/3986 . It is default, since it is known to have worked. The parameter can be set to 1 to switch to the code introduced by patch https://github.com/kamailio/kamailio/pull/3986.
I did a bit of testing and with `threads_mode = 0`, sending INVITEs didn't result in blocking.