From: Ralf S. <rs...@ru...> - 2016-03-23 16:15:03
|
On Tue, Mar 22, 2016 at 12:54:44PM -0500, Jeff LaCoursiere wrote: > > In testing I first noticed that about 30% of the time the script hangs, > thus I implemented the signal timeout. It seems to hang because I never > get the PeerlistComplete event. Is this a problem with asterisk not > sending it or some kind of bug in pyst? > > I next noticed that I rarely get the same number of peers: > > -------- > > root@jlpenha:/usr/local/bin# ./pypeers | wc -l > 27 > root@jlpenha:/usr/local/bin# ./pypeers | wc -l > 68 > root@jlpenha:/usr/local/bin# ./pypeers | wc -l > 71 > root@jlpenha:/usr/local/bin# ./pypeers | wc -l > 67 > root@jlpenha:/usr/local/bin# ./pypeers | wc -l > 64 You can debug this by looking with wireshark (or tcpdump) to the traffic on port 5038. This should show you in what sequence you receive which messages from asterisk. Looking at your code: You should *not* call ami.message_loop explicitly in your code. This is done behind the scenes by the ami implementation of pyst. So you're probably creating a race condition there between your call to ami.message_loop and the one that is called by a thread created in the __init__ method of the Manager object. So you really should leave all the processing to the thread created by Manager and do something else (sleep?) in the main program. Ralf -- Dr. Ralf Schlatterbeck Tel: +43/2243/26465-16 Open Source Consulting www: http://www.runtux.com Reichergasse 131, A-3411 Weidling email: of...@ru... |