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); }
In reply to Tk Mainloop - no exit. by Laotsu
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |