A problem with debugging threaded Python programs
I have a heavily threaded Python program that dies every now and then with a mysterious exception (that as far as I can see just shouldn't happen, which means that I don't completely understand my code).
My off and on attempts to debug this have pointed out a frustrating problem in Python's (lack of) support for debugging threaded Python programs: there's no such thing as a global exception, something that will freeze, backtrace, and terminate all threads when an error occurs. Instead, exceptions only capture the state of the thread they happen in, and only kill it.
(My program goes down because the exception is happening in the main thread, and all the other threads are short-lived.)
The irony is that Python's single-threaded bytecode interpreter would make this relatively easy to do. You could guarantee that the next bytecode-level action every other thread did was to throw an exception, and you'd be capturing pretty close to the exact state when the starting exception was created. (With some more work, you could make it an exact capture; just keep track of the last bytecode executed and generate the exception against it.)