in reply to Re^4: Why do my threads sometimes die silenty?
in thread Why do my threads sometimes die silenty?
When I run it, I get:use strict; use threads; use threads::shared; use Thread::Pool; my $signal = undef; share($signal); my $fct = sub { require Blah; Blah->import(); $signal = 1; }; print "Starting the Thread::Pool\n"; my $pool = Thread::Pool->new( {do => $fct}); print "Thread::Pool started\n"; print "Sending a job to the Thread::Pool\n"; $pool->job(); print "Job sent to the Thread::Pool\n"; print "Waiting for the slave thread to set the shared signal\n"; while (!$signal) { print "Sleeping and waiting for signal from slave thread\n"; sleep(1); } print "Got shared signal from slave thread\n"; $pool->shutdown();
And it gets stuck there, without outputting any error message. Obviously here, the slave gets a slice of CPU, since I sleep for 1 second between polls of the shared signal. Note that if I coment out the faulty require line, I do get the proper behaviour, i.e. the script prints:Starting the Thread::Pool
Starting the Thread::Pool Thread::Pool started Sending a job to the Thread::Pool Job sent to the Thread::Pool Waiting for the slave thread to set the shared signal Sleeping and waiting for signal from slave thread Got shared signal from slave thread
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Why do my threads sometimes die silenty?
by BrowserUk (Patriarch) on Sep 21, 2011 at 21:33 UTC | |
by alain_desilets (Beadle) on Sep 22, 2011 at 18:10 UTC | |
by BrowserUk (Patriarch) on Sep 22, 2011 at 19:15 UTC | |
by alain_desilets (Beadle) on Sep 23, 2011 at 12:38 UTC | |
by BrowserUk (Patriarch) on Sep 23, 2011 at 18:03 UTC |