[Python-Dev] unittest and sockets. Ugh!?

Tim Peters tim.one@comcast.net
Mon, 10 Jun 2002 11:30:22 -0400


BTW, if you want to run threads with unittest, I expect you'll have to
ensure that only the thread that starts unittest reports errors to unittest.
I'll call that "the main thread".  You should be aware that if a non-main
thread dies, unittest won't know that.  A common problem in the threaded
tests PLabs has written is that a thread dies an ignoble death but unittest
goes on regardless and says "ok!" at the end; if you didn't stare at all the
output, you never would have known something went wrong.

So wrap the body of your thread's work in a catch-all try/except, and if
anything goes wrong communicate that back to the main thread.  For example,
a Queue object (one or more) could work nicely for this.