I’m using wxpython to build the front-end GUI for a command-line tool that analyzes and processes audio files. The files are loaded into the GUI; then threads are launched that perform the analysis and adjustment steps; and finally the results of those processes are displayed in the main window.
I have endeavored to write thread safe code; however, some threads still arbitrarily fail to complete (it should be noted that when I manually launch them a second time, they typically run to completion). I have attached an abridged version of my program, which defines classes for the AnalysisThread, the AdjustThread, and the MainWindow. Buttons in the main window are bound to the functions “OnAnalyze” and “OnAdjust,” which create instances of the appropriate thread classes. The threads themselves communicate with the GUI via wx.CallAfter and Publisher. To my understanding, this should allow data to be passed safely back and forth between the main process and the threads. If someone could kindly point out where I went wrong with the attached code, I’d be very grateful.
If I cannot fix the thread safety issue, my back-up plan is to somehow detect the death of a thread and try to “resuscitate” it under the hood, without the user knowing there was a glitch. Does this seem reasonable? If so, advice on how to accomplish this would be most welcome.
Thanks very much.
Abridgedwxpython.txt (5.1 KB)