From: Josef N. <jos...@gm...> - 2007-11-27 16:07:09
|
In response to my own thread, I've put together a new script which does almost everything I need, except for properly handling multiple calls. I am almost certainly missing the boat with twisted/starpy here, because I cannot seem for the life of me to write a non-trivial location which will allow my box to process more than one incoming call at a time. As soon as I stick a time.sleep( 15 ) command in the script, the next call cant get through until the sleep finishes which is highly undesirable. Any suggestions for turning the attached example into something which will properly process multiple simultaneous calls without removing the sleep command would be deeply appreciated. -joe 2007/11/25, Josef Novak <jos...@gm...>: > Hi, > This is in response to a rather older thread, regarding handling > multiple calls. The script listed by the original poster works fine > for me, I am able to handle multiple calls with the same fastagi > instance. However, in the response to the poster's question: > >1. Is this the StarPythonic way to do this? Should I instead be > subclassing FastAgiFactory? > > Mike Fletcher wrote: > >The normal pattern in StarPy would be to create a core handler that > dispatches per-connection objects to handle a given call. See the > examples/calldurationcallback.py module for an example... > > However, I was unable to get the calldurationcallback.py example to > handle multiple calls. If I try to call in again while an earlier > call is still going on, the second call is forced to wait on the line > until the second one ends. This is obviously not very useful > behavior, so I wonder what it is that I am doing wrong. Is there a > particular way I should be starting up calldurationcallback.py, with > twistd and a specific set of arguments for example? Thus far the only > script I've been able to achieve this essential functionality with is > the below original posting for this thread, any specific advice in the > right direction regarding how to do this the starpy way, or even just > how to get the calldurationcallback.py to a point where it can field > multiple calls would be a great help. > > -joe > > >I am just getting going with StarPy and AGI (aka newbie) but I am dCap > >certified so I have a good understanding of asterisk in general. In my first > >attempt to understand StarPy I ran into an issue with handling more than one > >call into the same fastagi instance. It turns out this was pretty > easy to figure > >out, but I thought it would be good to share. I started with the following > >fastagi script: ... > > # START CODE > #!/usr/bin/env python > > from twisted.internet import reactor, defer > from starpy import fastagi, error > > import logging > log = logging.getLogger( 'testagi' ) > log.setLevel( logging.DEBUG ) > > class TestAgi( object ): > > def __call__( self , agi ): > > self.agi = agi > > log.debug("self.agi is now <%s>" % self.agi.variables['agi_uniqueid']) > > return self.agi.wait( 15 ).addCallback( self.waited1 ) > > def waited1( self, results ): > > log.debug("self.agi in waited1 now <%s>" % \ > self.agi.variables['agi_uniqueid']) > > return self.agi.hangup( ) > > if __name__ == "__main__": > logging.basicConfig() > fastagi.log.setLevel( logging.DEBUG ) > f = fastagi.FastAGIFactory(TestAgi( )) > reactor.listenTCP(4573, f, 50, '127.0.0.1') > reactor.run() > > # END CODE > |