I'm writing a utility to start up a django server process that outputs its logs to a TextCtrl in a wxpython window. Unfortunately, a couple different approaches have led to weird issues where the operating system (OSX in this case) crashing the program with complaints about "Illegal Instruction" after a few successful log entries.
I'm currently doing this by implementing a logging.Handler subclass that posts events to wx that contain the logging records to be shown in the window. Is there a better approach?
Thanks!
wxPython requires it to be the main thread, so I am guessing that is the likely root cause of your issue. You have a couple of good approaches to try though.
First you could launch the Django server process as a thread from your wxPython program. Then you can use wxPython's thread-safe methods (wx.CallAfter, wx.PostEvent) to communicate with the UI.
Or you could just launch Django separately and log to a file. Then launch wxPython and have it basically tail the log file.
Django logging to wxpython window?