[asterisk-users] Simplest way of executing a non-blocking (async) python AGI script?
J Montoya or A J Stiles
asterisk_list at earthshod.co.uk
Fri Jun 30 13:59:08 CDT 2017
On Friday 30 Jun 2017, Jonathan H wrote:
> What's the simplest, easiest quickest least-code way of firing off an AGI
> with some variable, and then returning to the dialplan?
You have to use the "fork" command. This starts a copy of the process with
all the same internal state including variables and filehandles. The command
returns a non-zero value (which is the PID of the child process; you may need
this, if you plan to outlive your children and have to clear their entries
from the process table) to the parent process, and zero to the child process.
So in the parent, you exit and return to the dialplan; and in the child, you
close STDIN, STDOUT and STDERR (so no process is waiting for you to produce
output), then just take your time doing what you have to. The parent is
already long dead by this time, so exiting goes nowhere.
> I've seen people talking about fastAGI, stasis, python ASYNC... all seems
> rather complicated. I feel I must be missing something embarrassingly
> obvious - isn't there just the equivalent of the unix shell's "&"?!
Yes, fork! That is what the "&" operator is using "under the bonnet".
--
JKLM
Note: Originating address only accepts e-mail from list! If replying off-
list, change address to asterisk1list at earthshod dot co dot uk .
More information about the asterisk-users
mailing list