>> I would expect... > The relative order of "Main thread finished." and "T before > sleep" is purely due to timing accidents...
Sure, I realize that the interactions between threads have no guaranteed order except what the programmer imposes upon them. I should have qualified my statement of expectation more carefully. > In fact, there are only two orderings you can count on here: > T before sleep < T after sleep > Main thread finished < atExitFunc called I understand your explanation and can live with the consequences, but the atexit docs sure don't prepare the reader for this. They say, "Functions thus registered are automatically executed upon normal interpreter termination." It seems like sophistry to argue that "normal interpreter termination" has occurred when there are still threads other than the main thread running. Suppose that today I promise to donate my body to science "upon my death", and tomorrow, I'm diagnosed with a gradual but inexorable illness that will kill me within ten years. I wouldn't expect to be strapped down and dissected immediately after hearing the diagnosis, on the basis that the mere prophecy of my death is tantamount to the death itself. -- http://mail.python.org/mailman/listinfo/python-list