[Asterisk-Users] Sending commands to Asterisk via FastAGI

Douglas Garstang dgarstang at oneeighty.com
Thu Jan 12 15:45:08 MST 2006


I have a fast agi python script that reads some numbers from MySQL, and then instructs asterisk to try those numbers in sequential order.

ie:

    def run(self):
        agi = AGI(self.client)

        db = MySQLdb.connect(host="192.168.10.15",user="user",passwd="password",db="somedb")
        c = db.cursor()
        c.execute("""Select * from ast_dp""")
        data = c.fetchall()
        
        for i in data:
            str = "EXEC " + i[4] + " \"" +i[5] + "/" + i[6] + "|" + i[7] + "\" \"\"\n"
            self.client.send(str)
            print str
        
        c.close()

I have noticed that when you send a list of instructions to Asterisk via AGI that Asterisk doesn't block on each command. It accepts all the commands at once, and must pool them internally I guess. This is different to regular AGI where Asterisk will not take the next command until the current one has finished processing (eg a dial with a timeout of 20s for example).

This seems to have the affect that when I hang up the caller, the first number stops ringing, and then the second will ring for a fraction of a second before also stopping. It's like Asterisk starts to process the command before it realises it's been cancelled. Not good!

Anyone seen this before? I was seeing a similar problem yesterday with a perl Agi script (not FastAGI). After hanging up the caller, the current callee would continue to ring for a fraction of a second after the caller had hung up. Also not good!

Thanks,
Douglas.





More information about the asterisk-users mailing list