it looks like $ssh is coming in undefined,
That doesn't happen with normal blessed objects:
#! perl -slw use strict; use threads; package Test; sub new{ bless [], $_[0] } sub exec{ print 'exec method called from thread: ', threads->tid } package main; my $o = Test->new; $o->exec; async{ $o->exec; }->detach; sleep 1; $o->exec; __END__ c:\test>tobj exec method called from thread: 0 exec method called from thread: 1 exec method called from thread: 0
Which probably means that there is some misbegotten code in Net::SSH2 that is attempting to make it "thread-safe".
The next thing to try is creating the ssh object inside the thread:
use threads; use Net::SSH2; async { my $ssh = Net::SSH2->new( ... ); $ssh->scp_put($firmware[$antenna_type],'/tmp/fwupdate.bin'); print "Upgrading firmware, this will take about 3 minutes.\n"; my $chan = $ssh->channel(); $chan->exec("/sbin/fwupdate -m\n"); $chan->close; }->detach; ...
Again, that ought to work, but I have no way to test this speculation!
In reply to Re^5: Net::SSH2 exec timeout
by BrowserUk
in thread Net::SSH2 exec timeout
by £okì
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |