TCL - 尝试并行执行 proc 但出现奇怪的 Java 错误

时间:2021-07-20 23:17:27

标签: tcl multiple-processes

我正在按照这里的示例进行操作 https://wiki.tcl-lang.org/page/Execute+in+Parallel+and+Wait 但是当我运行这样一个简单的代码时,我得到一个错误:子进程异常退出,错误是“错误:找不到或加载主类 引起:java.lang.ClassNotFoundException:"

    for {set i 0} {$i < 5} {incr i} {
        set script {            
            puts hello
        }
        set chan [open |[list [info nameofexecutable] <<$script 2>@stderr]]     
        dict set res $chan command $script
        fconfigure $chan -blocking 0
        lappend background $chan
    }
    
    while 1 {
        foreach chan $background {
            if {[eof $chan]} {
                fconfigure $chan -blocking 1
                if {[set idx [lsearch -exact $background $chan]] >= 0} {
                    set background [lreplace $background $idx $idx]
                }
                catch [close $chan] cres copts
                dict set res $chan result $cres
                dict set res $chan options $copts
            } else {
                puts -nonewline [read $chan]
            }
        }
        if {[llength $background] == 0} {
            break
        }
        after 100
    }
    return $res
}

}

当我尝试通过在 forloop 中运行此执行语句以稍微不同的方式运行并行进程时收到类似的消息

exec [info nameofexecutable] $variable_of_path_to_script << [list proc_name $param1 $param2] 2>@stderr

0 个答案:

没有答案