Laotsu has asked for the wisdom of the Perl Monks concerning the following question:
In the following code, if I comment out the calls to InitAsterisk and DoneAsterisk, MainLoop exits as expected. however, if I leave the calls in place, MainLoop never exits. ("1" is never printed, and a ctrl-C is needed to get a prompt back.
Normally, I would put the Init first, and the Done in the Exit sub, but I did this to show that simply calling InitAsterisk causes the problem. Even if the data is wrong and no connection is made to the AMI, the behavior is the same.
What have I done wrong? (karma aside)Ubuntu 10.04use Tk; use Asterisk::AMI::Common; my %config = ( user => "abuser", host => '192.168.1.22', secret => 'guessnot', port => '5038', ); &InitAsterisk; &DoneAsterisk; $top = MainWindow->new(); $button1 = $top->Button( -text => 'Exit', -command => sub { $top->des +troy; },)->pack; print "\n0\n"; MainLoop(); print "\n1\n"; exit; ############################################################ sub InitAsterisk { $asterisk = Asterisk::AMI->new(PeerAddr => $config{host}, PeerPort => $config{port}, Username => $config{user}, Secret => $config{secret}, ); die "Unable to connect to asterisk" unless ($asterisk); print "Asterisk connected\n"; } ############################################################ sub DoneAsterisk { print $asterisk->disconnect; print $asterisk->destroy; print "Asterisk disconnected\n"; die "Unable to DISCONNECT " unless ($asterisk); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Tk Mainloop - no exit.
by kcott (Archbishop) on Nov 08, 2010 at 06:56 UTC | |
by Laotsu (Initiate) on Nov 09, 2010 at 04:46 UTC | |
|
Re: Tk Mainloop - no exit.
by zentara (Cardinal) on Nov 08, 2010 at 12:13 UTC | |
by Laotsu (Initiate) on Nov 09, 2010 at 05:04 UTC | |
by zentara (Cardinal) on Nov 09, 2010 at 12:41 UTC | |
by Laotsu (Initiate) on Nov 11, 2010 at 05:40 UTC | |
by zentara (Cardinal) on Nov 11, 2010 at 13:00 UTC | |
|
Re: Tk Mainloop - no exit.
by rrb3942 (Initiate) on Nov 17, 2010 at 03:44 UTC |