[Freeswitch-users] mod_python and new Session from freeswitch.Session

Stanislav Sinyagin ssinyagin at gmail.com
Sat Oct 8 03:05:14 MSD 2016


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 at 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 at 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 at 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 at 192.168.100.28:5060
> [489d5441-701d-4a98-80ca-3389b00fa98a]
> freeswitch at 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 at 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 at Test-Environment>
> #
> # 12 seconds of silence during which any python script will not be executed
> and will be expected to complete
> #
> freeswitch at Test-Environment>
> 2016-10-07 17:55:45.140231 [NOTICE] sofia.c:8078 Hangup
> sofia/external-g-eth0.nostun.noauth/%2B71234567890 at 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 at 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 at 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 at 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 at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org



Join us at ClueCon 2016 Aug 8-12, 2016
More information about the FreeSWITCH-users mailing list