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!


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re^5: Net::SSH2 exec timeout by BrowserUk
in thread Net::SSH2 exec timeout by £okì

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.