mod_python and new Session from freeswitch.Session
Hi Guys.
From Dialplan run scripts in Python, from which I perform freeswitch.session("......"). That is, create a new session. And if I do not get an answer for a long time from the gateway, the execution of other scripts in Python is delayed until such time as the session will not be installed.
Please tell me how you can create a new session, and do not block completely mod_python. I understand that once had to be done through ESL, but now everything has already been written by the script from the dialplan. And it works, if it does not create a new session. freeswitch@Test-Environment> # # Execute python script from fs_cli(in dialer mode): # fs_cli --retry --batchmode --interrupt --execute="python python_test_script" # 2016-10-07 17:55:29.970991 [NOTICE] mod_python.c:212 Invoking py module: python_test_script 2016-10-07 17:55:30.119989 [NOTICE] switch_cpp.cpp:1360 -->(489d5441-701d-4a98-80ca-3389b00fa98a) Create a new session through freeswitch.Session("sofia/gateway/Goip_One/+71234567890@192.168.100.28:5060 ") 2016-10-07 17:55:30.119989 [NOTICE] switch_channel.c:1104 New Channel sofia/external-g-eth0.nostun.noauth/%2B71234567890@192.168.100.28:5060 [489d5441-701d-4a98-80ca-3389b00fa98a] freeswitch@Test-Environment> # # New incoming call # 2016-10-07 17:55:33.920114 [NOTICE] switch_channel.c:1104 New Channel sofia/external-g-eth0.stun.auth/384851@1.2.3.4 [e11d39b8-0479-4d4b-bd8b-28634f0a970a] 2016-10-07 17:55:33.920114 [INFO] mod_dialplan_xml.c:637 Processing 384851 <384851>->318386 in context hive-context # # Execute second python script from dialplan: # 2016-10-07 17:55:33.920114 [NOTICE] mod_python.c:212 Invoking py module: python_test_script freeswitch@Test-Environment> # # 12 seconds of silence during which any python script will not be executed and will be expected to complete # freeswitch@Test-Environment> 2016-10-07 17:55:45.140231 [NOTICE] sofia.c:8078 Hangup sofia/external-g-eth0.nostun.noauth/%2B71234567890@192.168.100.28:5060 [CS_CONSUME_MEDIA] [UNALLOCATED_NUMBER] 2016-10-07 17:55:45.160086 [NOTICE] switch_cpp.cpp:1360 -->(489d5441-701d-4a98-80ca-3389b00fa98a) After Create a new session through freeswitch.Session 2016-10-07 17:55:45.160086 [NOTICE] switch_core_session.c:1665 Session 15 (sofia/external-g-eth0.nostun.noauth/%2B71234567890@192.168.100.28:5060) Ended 2016-10-07 17:55:45.160086 [NOTICE] switch_core_session.c:1669 Close Channel sofia/external-g-eth0.nostun.noauth/% 2B71234567890@192.168.100.28:5060 [CS_DESTROY] # # Continue executing second python script(from 2016-10-07 17:55:33.920114) after any answer from first python new freeswitch.Session # 2016-10-07 17:55:45.160086 [ALERT] switch_cpp.cpp:1360 (mtid:3656): Traceback 280920161717(e11d39b8-0479-4d4b-bd8b-28634f0a970a): --> 12 <--; now: 1475841345; python_start_time:1475841333;
here's my example for mod_perl, and mod_python will work similarly: https://github.com/xlab1/freeswitch_secretary_bug/tree/master/scripts The trick is to execute a background thread with "perlrun" API call. But ESL is much more flexible in handling this scenario, and here's an example too: https://github.com/xlab1/go-fs-secretary-prototype/tree/master/golang On Fri, Oct 7, 2016 at 2:29 PM, Андрей Асташов <astashov.andrey@gmail.com> wrote:
Hi Guys.
From Dialplan run scripts in Python, from which I perform freeswitch.session("......"). That is, create a new session. And if I do not get an answer for a long time from the gateway, the execution of other scripts in Python is delayed until such time as the session will not be installed.
Please tell me how you can create a new session, and do not block completely mod_python. I understand that once had to be done through ESL, but now everything has already been written by the script from the dialplan. And it works, if it does not create a new session.
freeswitch@Test-Environment> # # Execute python script from fs_cli(in dialer mode): # fs_cli --retry --batchmode --interrupt --execute="python python_test_script" # 2016-10-07 17:55:29.970991 [NOTICE] mod_python.c:212 Invoking py module: python_test_script 2016-10-07 17:55:30.119989 [NOTICE] switch_cpp.cpp:1360 -->(489d5441-701d-4a98-80ca-3389b00fa98a) Create a new session through freeswitch.Session("sofia/gateway/Goip_One/+71234567890@192.168.100.28:5060") 2016-10-07 17:55:30.119989 [NOTICE] switch_channel.c:1104 New Channel sofia/external-g-eth0.nostun.noauth/%2B71234567890@192.168.100.28:5060 [489d5441-701d-4a98-80ca-3389b00fa98a] freeswitch@Test-Environment> # # New incoming call # 2016-10-07 17:55:33.920114 [NOTICE] switch_channel.c:1104 New Channel sofia/external-g-eth0.stun.auth/384851@1.2.3.4 [e11d39b8-0479-4d4b-bd8b-28634f0a970a] 2016-10-07 17:55:33.920114 [INFO] mod_dialplan_xml.c:637 Processing 384851 <384851>->318386 in context hive-context # # Execute second python script from dialplan: # 2016-10-07 17:55:33.920114 [NOTICE] mod_python.c:212 Invoking py module: python_test_script freeswitch@Test-Environment> # # 12 seconds of silence during which any python script will not be executed and will be expected to complete # freeswitch@Test-Environment> 2016-10-07 17:55:45.140231 [NOTICE] sofia.c:8078 Hangup sofia/external-g-eth0.nostun.noauth/%2B71234567890@192.168.100.28:5060 [CS_CONSUME_MEDIA] [UNALLOCATED_NUMBER] 2016-10-07 17:55:45.160086 [NOTICE] switch_cpp.cpp:1360 -->(489d5441-701d-4a98-80ca-3389b00fa98a) After Create a new session through freeswitch.Session 2016-10-07 17:55:45.160086 [NOTICE] switch_core_session.c:1665 Session 15 (sofia/external-g-eth0.nostun.noauth/%2B71234567890@192.168.100.28:5060) Ended 2016-10-07 17:55:45.160086 [NOTICE] switch_core_session.c:1669 Close Channel sofia/external-g-eth0.nostun.noauth/%2B71234567890@192.168.100.28:5060 [CS_DESTROY] # # Continue executing second python script(from 2016-10-07 17:55:33.920114) after any answer from first python new freeswitch.Session # 2016-10-07 17:55:45.160086 [ALERT] switch_cpp.cpp:1360 (mtid:3656): Traceback 280920161717(e11d39b8-0479-4d4b-bd8b-28634f0a970a): --> 12 <--; now: 1475841345; python_start_time:1475841333;
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
Thank you so much. I, too, yesterday in the evening came to a decision to use bgapi originate command, and then connect to it through uuid. It seems to work as it should, but I think that this is not the right decision anyway. Already came across as much rake that I regret that he chose python and regrets that he started to write through ESL. :) I will be rewritten. 2016-10-08 5:05 GMT+06:00 Stanislav Sinyagin <ssinyagin@gmail.com>:
But ESL is much more flexible in handling this scenario, and here's an example too:
I would recommend perl and ESL with bgapi originate, works perfectly. I've using it forever. My difference is that i have one script to generate the call and another to process vie ESL whatever i need to process once it's been launched. On Sat, Oct 8, 2016 at 7:07 AM Андрей Асташов <astashov.andrey@gmail.com> wrote:
Thank you so much.
I, too, yesterday in the evening came to a decision to use bgapi originate command, and then connect to it through uuid. It seems to work as it should, but I think that this is not the right decision anyway. Already came across as much rake that I regret that he chose python and regrets that he started to write through ESL. :)
I will be rewritten.
2016-10-08 5:05 GMT+06:00 Stanislav Sinyagin <ssinyagin@gmail.com>:
But ESL is much more flexible in handling this scenario, and here's an example too:
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
And why perl? What are its features in comparison with python? Just python I know more and understand what a perl, and I would like to know better than perl to write a programm for telephony services. 2016-10-08 19:18 GMT+06:00 David Villasmil <david.villasmil.work@gmail.com>:
I would recommend perl and ESL with bgapi originate, works perfectly. I've using it forever. My difference is that i have one script to generate the call and another to process vie ESL whatever i need to process once it's been launched. On Sat, Oct 8, 2016 at 7:07 AM Андрей Асташов <astashov.andrey@gmail.com> wrote:
Thank you so much.
I, too, yesterday in the evening came to a decision to use bgapi originate command, and then connect to it through uuid. It seems to work as it should, but I think that this is not the right decision anyway. Already came across as much rake that I regret that he chose python and regrets that he started to write through ESL. :)
I will be rewritten.
2016-10-08 5:05 GMT+06:00 Stanislav Sinyagin <ssinyagin@gmail.com>:
But ESL is much more flexible in handling this scenario, and here's an example too:
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
No special reason, i use perl for decades now. I can't give you a reason not to use python. The point is not really the language, but the functions used. Which i guess are available for python as well. On Sat, Oct 8, 2016 at 4:14 PM Андрей Асташов <astashov.andrey@gmail.com> wrote:
And why perl? What are its features in comparison with python? Just python I know more and understand what a perl, and I would like to know better than perl to write a programm for telephony services.
2016-10-08 19:18 GMT+06:00 David Villasmil <david.villasmil.work@gmail.com
:
I would recommend perl and ESL with bgapi originate, works perfectly. I've using it forever. My difference is that i have one script to generate the call and another to process vie ESL whatever i need to process once it's been launched. On Sat, Oct 8, 2016 at 7:07 AM Андрей Асташов <astashov.andrey@gmail.com> wrote:
Thank you so much.
I, too, yesterday in the evening came to a decision to use bgapi originate command, and then connect to it through uuid. It seems to work as it should, but I think that this is not the right decision anyway. Already came across as much rake that I regret that he chose python and regrets that he started to write through ESL. :)
I will be rewritten.
2016-10-08 5:05 GMT+06:00 Stanislav Sinyagin <ssinyagin@gmail.com>:
But ESL is much more flexible in handling this scenario, and here's an example too:
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
sounds like there is some come missing to tell python we are entering into a long running c function. Let's move this to jira and i'll take a look in the morning. This is the kind of info i needed to help track down why python might be blocking. I'll see if i'm right on my suspicion tomorrow On Friday, October 7, 2016, Андрей Асташов <astashov.andrey@gmail.com> wrote:
Hi Guys.
From Dialplan run scripts in Python, from which I perform freeswitch.session("......"). That is, create a new session. And if I do not get an answer for a long time from the gateway, the execution of other scripts in Python is delayed until such time as the session will not be installed.
Please tell me how you can create a new session, and do not block completely mod_python. I understand that once had to be done through ESL, but now everything has already been written by the script from the dialplan. And it works, if it does not create a new session.
freeswitch@Test-Environment> # # Execute python script from fs_cli(in dialer mode): # fs_cli --retry --batchmode --interrupt --execute="python python_test_script" # 2016-10-07 17:55:29.970991 [NOTICE] mod_python.c:212 Invoking py module: python_test_script 2016-10-07 17:55:30.119989 [NOTICE] switch_cpp.cpp:1360 -->(489d5441-701d-4a98-80ca-3389b00fa98a) Create a new session through freeswitch.Session("sofia/gateway/Goip_One/+71234567890@ 192.168.100.28:5060") 2016-10-07 17:55:30.119989 [NOTICE] switch_channel.c:1104 New Channel sofia/external-g-eth0.nostun.noauth/%2B71234567890@192.168.100.28:5060 [489d5441-701d-4a98-80ca-3389b00fa98a] freeswitch@Test-Environment> # # New incoming call # 2016-10-07 17:55:33.920114 [NOTICE] switch_channel.c:1104 New Channel sofia/external-g-eth0.stun.auth/384851@1.2.3.4 <javascript:_e(%7B%7D,'cvml','384851@1.2.3.4');> [e11d39b8-0479-4d4b-bd8b- 28634f0a970a] 2016-10-07 17:55:33.920114 [INFO] mod_dialplan_xml.c:637 Processing 384851 <384851>->318386 in context hive-context # # Execute second python script from dialplan: # 2016-10-07 17:55:33.920114 [NOTICE] mod_python.c:212 Invoking py module: python_test_script freeswitch@Test-Environment> # # 12 seconds of silence during which any python script will not be executed and will be expected to complete # freeswitch@Test-Environment> 2016-10-07 17:55:45.140231 [NOTICE] sofia.c:8078 Hangup sofia/external-g-eth0.nostun.noauth/%2B71234567890@192.168.100.28:5060 [CS_CONSUME_MEDIA] [UNALLOCATED_NUMBER] 2016-10-07 17:55:45.160086 [NOTICE] switch_cpp.cpp:1360 -->(489d5441-701d-4a98-80ca-3389b00fa98a) After Create a new session through freeswitch.Session 2016-10-07 17:55:45.160086 [NOTICE] switch_core_session.c:1665 Session 15 (sofia/external-g-eth0.nostun.noauth/%2B71234567890@192.168.100.28:5060) Ended 2016-10-07 17:55:45.160086 [NOTICE] switch_core_session.c:1669 Close Channel sofia/external-g-eth0.nostun.noauth/%2B71234567890@192.168. 100.28:5060 [CS_DESTROY] # # Continue executing second python script(from 2016-10-07 17:55:33.920114) after any answer from first python new freeswitch.Session # 2016-10-07 17:55:45.160086 [ALERT] switch_cpp.cpp:1360 (mtid:3656): Traceback 280920161717(e11d39b8-0479-4d4b-bd8b-28634f0a970a): --> 12 <--; now: 1475841345; python_start_time:1475841333;
participants (4)
-
David Villasmil
-
Michael Jerris
-
Stanislav Sinyagin
-
Андрей Асташов