Multithreading Tcl中的线程出错-在线程内寻源时没有此类变量错误
得到一个错误,无法读取“chan”没有这样的变量,它包含在我正在寻找的文件中,在另一个文件的线程中,chan甚至不在我与我的线程一起使用的文件中Multithreading Tcl中的线程出错-在线程内寻源时没有此类变量错误,multithreading,tcl,Multithreading,Tcl,得到一个错误,无法读取“chan”没有这样的变量,它包含在我正在寻找的文件中,在另一个文件的线程中,chan甚至不在我与我的线程一起使用的文件中 thread::send $function { source xyz source zyx source yzx } xyz包含一个已完成且与此文件无关的变量,但在执行“ProcedureInOtherFile”事件时出现错误“无法读取”chan从“源xyz”中调用“$chan”时没有此类变量 c
thread::send $function {
source xyz
source zyx
source yzx
}
xyz包含一个已完成且与此文件无关的变量,但在执行“ProcedureInOtherFile”事件时出现错误“无法读取”chan从“源xyz”中调用“$chan”时没有此类变量
chan甚至不在我使用的线程文件中
thread::send $function {
source xyz
source zyx
source yzx
}
确切地说:)您的期望是什么?您似乎以黑盒方式源代码一些现有的Tcl脚本,而没有满足被调用方的要求
观察:
% package req Thread
2.8.2
% set fh [open "/tmp/foo.tcl" w]
file5
% puts $fh {puts $chan "hello world"}
% close $fh
% set t1 [thread::create]
tid0x700004a5c000
% thread::send $t1 { source /tmp/foo.tcl }
can't read "chan": no such variable
% thread::send $t1 { set chan stderr; source /tmp/foo.tcl }
hello world
% thread::release $t1
0
% exit
chan甚至不在我使用的线程文件中
thread::send $function {
source xyz
source zyx
source yzx
}
确切地说:)您的期望是什么?您似乎以黑盒方式源代码一些现有的Tcl脚本,而没有满足被调用方的要求
观察:
% package req Thread
2.8.2
% set fh [open "/tmp/foo.tcl" w]
file5
% puts $fh {puts $chan "hello world"}
% close $fh
% set t1 [thread::create]
tid0x700004a5c000
% thread::send $t1 { source /tmp/foo.tcl }
can't read "chan": no such variable
% thread::send $t1 { set chan stderr; source /tmp/foo.tcl }
hello world
% thread::release $t1
0
% exit
您能否通过提供一个与您的情况相匹配的实际示例来改进您的描述?恐怕,您描述所感知的问题的方式没有特别大的帮助。请参阅我试图为您提供一个沙盒REPL示例。您能否通过提供一个与您的情况相匹配的实际示例来改进您的描述?恐怕,您描述感知到的问题的方式并没有特别的帮助。请参阅我试图为您提供的沙盒REPL示例。要补充此答案,请记住每个线程都有自己的解释器和自己的变量。它们不是共享的;如果希望它们存在,您必须显式地传递它们。此外,除了标准的(stdin
,stdout
和stderr
)默认情况下,仅在其原始解释器中可见。要添加到此答案,请记住每个线程都有自己的解释器和自己的变量。它们不是共享的;如果希望它们存在,则必须显式传递它们。此外,还有标准通道以外的通道默认情况下,(stdin
、stdout
和stderr
)仅在其原始解释器中可见。