in reply to SOAP::Lite How to use persistent connection across fork process

Threads is perfect for this. You could create 1 Soap::Lite object and keep using it over and over. This is untested, but is simple to understand what is happening. I would use Glib or AnyEvent to make a timer to wake the thread, but this while loop shows the simplicity.
#!/usr/bin/perl use warnings; use strict; use threads; use threads::shared; my $tgo:shared = 0;; my $tdie:shared = 0; my $thread = threads->new(\&check_it); # setup a timer or use a while loop here # probably need to Control-C out of this loop # unless you add some keyboard checking for a q # or whatever while(1){ sleep 10; $tgo = 1; print "starting check\n"; } $tdie = 1; $thread->join; print "done press any key to exit\n"; <>; ################################################### sub check_it { use SOAP::Lite; $|++; # this will be persistent in the thread my $soap_client = SOAP::Lite->uri('myuri') ->proxy('http://serviceendpoint', timeout => 30, keep_alive => 1); while(1){ if($tdie == 1){ return }; if ( $tgo == 1 ){ print "soap start\n"; $soap_client->call('SomeMethod',$paramter); print "soap done\n"; $tgo = 0; #turn off self before returning to sleep }else { sleep 1 } } } __END__

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh
  • Comment on Re: SOAP::Lite How to use persistent connection across fork process
  • Download Code