Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  nodelist  faq  login

The system was down for backups from 5am to 10am last Saturday.


programming / comp.lang.tcl / thread pool bug ??

SubjectAuthor
* thread pool bug ??Cyrille Duret
`* Re: thread pool bug ??Schelte
 `- Re: thread pool bug ??Cyrille Duret

1
Subject: thread pool bug ??
From: Cyrille Duret
Newsgroups: comp.lang.tcl
Date: Mon, 25 Apr 2022 09:43 UTC
X-Received: by 2002:ac8:5e09:0:b0:2f3:54b5:c2f2 with SMTP id h9-20020ac85e09000000b002f354b5c2f2mr11068868qtx.267.1650879803438;
Mon, 25 Apr 2022 02:43:23 -0700 (PDT)
X-Received: by 2002:a05:6870:51cb:b0:e2:aafb:cbb9 with SMTP id
b11-20020a05687051cb00b000e2aafbcbb9mr10529234oaj.39.1650879803172; Mon, 25
Apr 2022 02:43:23 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Mon, 25 Apr 2022 02:43:22 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=195.65.152.113; posting-account=a9y7ZAkAAADa-ec0gIEVjED39feWqg2-
NNTP-Posting-Host: 195.65.152.113
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <e2478d4e-5b86-40df-9399-ec7629229428n@googlegroups.com>
Subject: thread pool bug ??
From: cdu...@gmail.com (Cyrille Duret)
Injection-Date: Mon, 25 Apr 2022 09:43:23 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 54
View all headers
Hello I try to use thread pool (2.8.5) with tcl 8.6.8-2 on a redhat 8 virtual machine and I have real problem with waiting for all jobs to finish:

package require Thread
set pool [tpool::create -maxworkers 4]
set jobs {}
for {set i 0} {$i < 50} {incr i} {
  lappend jobs [tpool::post $pool [string map [list {$i} $i] {
    puts "thread $i.."
    after 1000
  }]]
}
tpool::wait $pool $jobs
puts "#### finished ####"


The pool::wait command never wait for completion of all threads

My output is :

thread 0..
thread 1..
thread 2..
thread 3..
thread 4..
thread 5..
thread 6..
thread 7..
thread 8..
thread 9..
thread 10..
thread 11..
thread 12..
thread 13..
thread 14..
thread 15..
thread 16..
thread 17..
thread 18..
thread 19..
thread 20..
#### finished ####
% thread 21..
thread 22..
thread 23..
thread 24..
thread 25..
thread 26..
thread 27..

I encountered same kind of problem with my gentoo linux laptop but this code works fine on windows.

Any idea on what is going on ?

thanks
Cyrille


Subject: Re: thread pool bug ??
From: Schelte
Newsgroups: comp.lang.tcl
Organization: KPN B.V.
Date: Mon, 25 Apr 2022 10:19 UTC
References: 1
Date: Mon, 25 Apr 2022 12:19:28 +0200
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.8.1
Subject: Re: thread pool bug ??
Content-Language: en-US
Newsgroups: comp.lang.tcl
References: <e2478d4e-5b86-40df-9399-ec7629229428n@googlegroups.com>
From: nos...@wanadoo.nl (Schelte)
In-Reply-To: <e2478d4e-5b86-40df-9399-ec7629229428n@googlegroups.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <nnd$1563690d$3164a242@e11b7414ddc6c555>
Organization: KPN B.V.
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!news-out.netnews.com!news.alt.net!fdc2.netnews.com!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!abe005.abavia.com!abp001.abavia.com!news.kpn.nl!not-for-mail
Lines: 17
Injection-Date: Mon, 25 Apr 2022 12:19:28 +0200
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
X-Received-Bytes: 1372
View all headers
On 25/04/2022 11:43, Cyrille Duret wrote:
The pool::wait command never wait for completion of all threads

The tpool::wait command is documented to "wait for the first job to get ready". It returns the completed job IDs, and puts the job IDs that are still pending in the varname argument, if provided.

If you want to wait for all jobs to be ready, you have to call tpool::wait in a loop. Something like this:

while {[llength $jobs]} {
     tpool::wait $pool $jobs jobs
}


Schelte.


Subject: Re: thread pool bug ??
From: Cyrille Duret
Newsgroups: comp.lang.tcl
Date: Mon, 25 Apr 2022 12:03 UTC
References: 1 2
X-Received: by 2002:a0c:c788:0:b0:444:2c7f:4126 with SMTP id k8-20020a0cc788000000b004442c7f4126mr12212011qvj.50.1650888226791;
Mon, 25 Apr 2022 05:03:46 -0700 (PDT)
X-Received: by 2002:a05:6808:1646:b0:2f7:50ea:85f3 with SMTP id
az6-20020a056808164600b002f750ea85f3mr11591212oib.137.1650888226306; Mon, 25
Apr 2022 05:03:46 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Mon, 25 Apr 2022 05:03:46 -0700 (PDT)
In-Reply-To: <nnd$1563690d$3164a242@e11b7414ddc6c555>
Injection-Info: google-groups.googlegroups.com; posting-host=195.65.152.113; posting-account=a9y7ZAkAAADa-ec0gIEVjED39feWqg2-
NNTP-Posting-Host: 195.65.152.113
References: <e2478d4e-5b86-40df-9399-ec7629229428n@googlegroups.com> <nnd$1563690d$3164a242@e11b7414ddc6c555>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <adecd307-76a7-459d-924e-93906d1ef76cn@googlegroups.com>
Subject: Re: thread pool bug ??
From: cdu...@gmail.com (Cyrille Duret)
Injection-Date: Mon, 25 Apr 2022 12:03:46 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 21
View all headers
Le Monday, April 25, 2022 à 12:19:33 PM UTC+2, Schelte a écrit :
On 25/04/2022 11:43, Cyrille Duret wrote:
The pool::wait command never wait for completion of all threads

The tpool::wait command is documented to "wait for the first job to get
ready". It returns the completed job IDs, and puts the job IDs that are
still pending in the varname argument, if provided.

If you want to wait for all jobs to be ready, you have to call
tpool::wait in a loop. Something like this:

while {[llength $jobs]} {
tpool::wait $pool $jobs jobs
}


Schelte.

thank you very much !


1
rocksolid light 0.7.2
clearneti2ptor