Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Crash with ForkManager on Windows

by holli (Abbot)
on Sep 20, 2017 at 19:57 UTC ( [id://1199778]=note: print w/replies, xml ) Need Help??


in reply to Crash with ForkManager on Windows

Try wrapping the relevant parts of your code in try/catch blocks and see if it is dying somewhere unexpectedly.


holli

You can lead your users to water, but alas, you cannot drown them.

Replies are listed 'Best First'.
Re^2: Crash with ForkManager on Windows
by amitsq (Beadle) on Sep 21, 2017 at 10:01 UTC
    ok i did that. Can't see why value shouldn't be defined though :/
    Can't call method "start" on an undefined value at line 18. Can't call method "finish" on an undefined value at .\multithreadsTe\3 +.pl line 25. </code which basically are following lines in my code: <code> line 18: $pm->start and next LINKS; line 25: $pm->finish;
    my modified code again:
    #!d:\perl\bin\perl.exe use Parallel::ForkManager; use LWP::Simple; use Try::Tiny; try{ my $pm = Parallel::ForkManager->new(6);} catch {print "error 1 \n"; exit;}; LINKS: for my $link ('http://us.a1.yimg.com/us.yimg.com/i/ww/m5v9.gif', 'http://hooboy.no-such-host.int/', 'http://www.yahoo.com', 'http://www.ora.com/ask_tim/graphics/asktim_header_main.gif', 'http://www.guardian.co.uk/', 'http://www.pixunlimited.co.uk/siteheaders/Guardian.gif') { try { $pm->start and next LINKS; } catch { warn $_; print "### ", $link, " \n error 2 \n"; next;}; try{ my ($content_type, $document_length, $modified_time, $expires, $ +server) = head($link); print "$link fetched: declared lenght $document_length, \n"; } catch{print "error 3 \n";}; try{$pm->finish; } catch{ warn $_; print "error 4 \n";}; };
      Can't see why value shouldn't be defined though
      Because you defined $pm lexically in the try - block and you don't have strict on.

      Edit:
      I just ran your code with the issue fixed but experience no crashes (Win 8.1, ActivePerl 5.24). I think there is something broken with your installation of the module and or Perl itself. I suggest a clean reinstall of both.


      holli

      You can lead your users to water, but alas, you cannot drown them.
        sorry my bad.

        I corrected that, and it results in no error msg output anymore. But it crashed again, with again no error output on the console although the catch blocks are implemented.

        i am afraid it's a problem with the installation.

        usually i install new moduls per package manager, so i removed the ForkManager Modul and tried to install it from the console:
        New CPAN.pm version (v2.16) available. [Currently running version is v1.9800] You might want to try install CPAN reload cpan to both upgrade CPAN.pm and run the new version without leaving the current session.
        then i updated Cpan.pm, and now the error when trying to install forkmanager is:
        PS cpan Parallel-ForkManager Set up gcc environment - gcc.exe (rubenvb-4.5.4) 4.5.4 Loading internal null logger. Install Log::Log4perl for logging messag +es CPAN: Term::ANSIColor loaded ok (v4.02) CPAN: Storable loaded ok (v2.45) Reading 'D:\Perl64\cpan\Metadata' Database was generated on Thu, 21 Sep 2017 05:41:02 GMT Warning: Cannot install Parallel-ForkManager, don't know what it is. Try the command i /Parallel-ForkManager/ to find objects with matching identifiers. CPAN: Time::HiRes loaded ok (v1.9726)
      By wrapping the
      my $pm = Parallel::ForkManager->new(6);
      into a try block, $pm now is local to that new block … I think strict would have told you about it.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1199778]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (8)
As of 2024-04-19 09:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found