pryrt has asked for the wisdom of the Perl Monks concerning the following question:
So, I started playing around with threads, using Re: buffering zipped pipes as an example. I got something working on my Windows machine, then tried it out on the ancient linux box (perl 5.8.5)... and got the dreaded "A thread exited while 2 threads were running."
I double-checked to make sure that the linux box's perldoc threads claimed support for ->detach, and the WARNINGS section suggested joining to remove the error. I thought ->detach was supposed to make it automatically clean up such stuff.
I tried no warnings 'threads'; or even no warnings;, just to see if I could make the warning go away, but it stuck around.
Given the details (below), how can I get around this warning? Can I install a new local version of threads on the linux machine (I have cpan set up for local library installs), or is threads too core to be able to update with cpan? Or should I just switch to not using ->detach, and do manual cleanup using ->join?
tl;dr details follow...
C:> perl -v | head -2 | tail -1 This is perl 5, version 24, subversion 0 (v5.24.0) built for MSWin32-x +64-multi-thread C:> perl -V | egrep "thread.*=" useithreads=define, usemultiplicity=define C:> perl -Mthreads -le "print $threads::VERSION;" 2.07 C:> perl -Mthreads -le "async { sleep 100; } ; exit;" Perl exited with active threads: 1 running and unjoined 0 finished and unjoined 0 running and detached C:> perl -Mthreads -le "async { sleep 100; }->detach ; exit;" C:>
$ perl -v | head -2 | tail -1 This is perl, v5.8.5 built for i386-linux-thread-multi $ perl -V | egrep 'thread.*=' config_args='-des -Doptimize=-O2 -g -pipe -m32 -march=i386 -mtune= +pentium4 -Dversion=5.8.5 -Dmyhostname=localhost -Dperladmin=root@loca +lhost -Dcc=gcc -Dcf_by=Red Hat, Inc. -Dinstallprefix=/usr -Dprefix=/u +sr -Darchname=i386-linux -Dvendorprefix=/usr -Dsiteprefix=/usr -Duses +hrplib -Dusethreads -Duseithreads -Duselargefiles -Dd_dosuid -Dd_semc +tl_semun -Di_db -Ui_ndbm -Di_gdbm -Di_shadow -Di_syslog -Dman3ext=3pm + -Duseperlio -Dinstallusrbinperl -Ubincompat5005 -Uversiononly -Dpage +r=/usr/bin/less -isr -Dinc_version_list=5.8.4 5.8.3 5.8.2 5.8.1 5.8.0 +' usethreads=define use5005threads=undef useithreads=define usemulti +plicity=define $ perl -Mthreads -le 'print $threads::VERSION;' 1.05 $ perl -Mthreads -le 'async { sleep 100; } ; exit;' A thread exited while 2 threads were running. $ perl -Mthreads -le 'async { sleep 100; }->detach ; exit;' A thread exited while 2 threads were running. $ perl -Mthreads -le 'no warnings; async { sleep 100; }->detach ; exit +;' A thread exited while 2 threads were running. $
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: detached threads still warn
by hippo (Archbishop) on Oct 07, 2016 at 16:04 UTC | |
Re: detached threads still warn
by BrowserUk (Patriarch) on Oct 07, 2016 at 16:51 UTC | |
by pryrt (Abbot) on Oct 07, 2016 at 17:11 UTC | |
by stevieb (Canon) on Oct 07, 2016 at 17:38 UTC |