• thread pool bug ??

    From Cyrille Duret@21:1/5 to All on Mon Apr 25 02:43:22 2022
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Schelte@21:1/5 to Cyrille Duret on Mon Apr 25 12:19:28 2022
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Cyrille Duret@21:1/5 to All on Mon Apr 25 05:03:46 2022
    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 !

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)