Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Completely Random Stall

by chrism01 (Friar)
on Jun 13, 2008 at 07:02 UTC ( [id://691854]=note: print w/replies, xml ) Need Help??


in reply to Completely Random Stall

I'd like to second BrowserUK's advice, esp re use strict, warnings.
Also, replace your system() calls with the built-in Perl equivalents, which will give you better error handling and remove the process-creation overhead you're getting.
As well, check for errors in opendir() : http://perldoc.perl.org/perlopentut.html.
BTW, forking != threading.

Replies are listed 'Best First'.
Re^2: Completely Random Stall
by expresspotato (Beadle) on Apr 27, 2009 at 18:09 UTC
    Hi Monks! I'm still having the same problems... A few hundred threads in, the script decides to stop working. How should I be cleaning up after the thread has finished? Any help is appreciated.
    #! /usr/bin/perl use threads; $|++; print "Running...\n"; while(1){ opendir(DIR2,"./bgthread/process"); @list3 = readdir(DIR2); close( +DIR2); $line = ""; @items = ""; foreach (@list3){ $line = $_; chomp($line); if (($line ne ".") && ($line ne "..")){ ($buffer,$do,$torrent) = split(/\-\.\-/,$line); print "Sending ($line)\n"; $thr = threads->new(\&do_thread); $thr->detach; } } if (-e "./bgthread_refresh"){ exit; } sleep(1); #system("sleep 0.5"); print ":"; } sub do_thread(){ system("perl bgthread_processor.pl $line"); #goto &nothing; } sub nothing(){ #Do nothing... undef $line; }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-03-28 13:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found