[Xotcl] setExitHandler & threads

Scott Gargash scottg at atc.creative.com
Thu Aug 17 00:13:38 CEST 2006






Gustaf Neumann <neumann at wu-wien.ac.at> wrote on 08/16/2006 03:06:18 AM:

> Scott Gargash schrieb:
> >
> > So I inserted my own exitHandler and that works in a single thread,
> > but when I have multiple threads, things get confused.
> >
> You have not told us, what "confused" means (other than: "i get an
> error") since your
> example works for me.

Sorry, I omitted that.  My example gives the following error:

Error from thread tid00000C20
invalid command name "tclPkgUnknown"
    while executing
"tclPkgUnknown XOTcl {}"
    ("package unknown" script)
    invoked from within
"package require XOTcl"
User defined exit handler contains errors!
Error in line 2: target thread died
Execution interrupted.


My actual code doesn't give any consistent behavior.  Sometimes it sort of works, sometimes it
generates corrupt data, and sometimes it dumps core.

> If you have multiple threads, and you want to control the order, in
> which the threads exit
> (and in which their exit handlers are called), you have to do this on
> your own
> as well (not using "exit", but your own shutdown command). Be aware of,
> that tcl tries to shutdown your threads on exit as well.


A ha, you've describe my problem (and also the solution I found).  I have exit handlers in all the
threads, and I get inconsistent behavior.  I wound up overriding exit to get things to exit in a
defined manner.

It was in the process of trying to reduce it down to a simple test case that I found the problem
(described above) on WinXP with just a single exit handler.  Now, perhaps that's an real problem of
some sort also, but it sounds like I need to continue overriding "exit" to get the desired behavior
in the real codebase.

      Scott

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://alice.wu-wien.ac.at/pipermail/xotcl/attachments/20060816/dd8f6a6e/attachment.html


More information about the Xotcl mailing list