Description: |
(text/x-fossil-wiki)
When the following script is evaluated in a core-8-branch build, the bgerror
procedure registered in the "main" interp is called, while the bgerror
procedure registered in the "worker" interp is ignored:
<code><verbatim>
package require Thread
proc bg args {
puts [list {main error handler} $args]
}
interp bgerror {} bg
after 0 {
interp create t1
set thread [thread::create]
thread::send -async $thread {
proc bg args {
puts stderr [list {thread error handler} $args]
flush stderr
}
interp bgerror {} bg
}
thread::send -async $thread {error {an error}} a
}
vwait forever
</verbatim></code>
Output:
<code><verbatim>
an error
while executing
"error {an error}"
Error from thread tid0x7f0b594fb740
an error
{main error handler} {{an error} {-code 1 -level 0 -errorstack {INNER {invokeStk1 open /home/yorick/opt/tcl_thread--2_branch/lib/tclIndex} CALL auto_load_index} -errorcode NONE -errorinfo {an error} -errorline 1}}
</verbatim></code>
If there is no bgerror procedure in the "main" interp, the bgerror procedure in
the "worker" interp is ignored entirely:
<code><verbatim>
package require Thread
after 0 {
interp create t1
set thread [thread::create]
thread::send -async $thread {
proc bg args {
puts stderr [list {thread error handler} $args]
flush stderr
}
interp bgerror {} bg
}
thread::send -async $thread {error {an error}} a
}
vwait forever
</verbatim></code>
Output:
<code><verbatim>
Error from thread tid0x7f5f12394640
an error
while executing
"error {an error}"
Error from thread tid0x7f5f12959740
an error
an error
</verbatim></code>
|