Multi-threaded app: simultaneous event handling?

Hello,

I have a wxPython 2.6.x (using GTK) app with a single main wx.Frame and a number of worker threads (Python threading.Thread objects).
Each thread handles a socket connection and whenever new data arrives on a connection an event is sent to the main frame. These events are in the form of a few custom event classes, e.g.

wx_EVT_SET_PARAMETERS = wx.NewEventType()
EVT_SET_PARAMETERS = wx.PyEventBinder(wx_EVT_SET_PARAMETERS, 1)

class SetParametersEvent(wx.PyEvent):

    def __init__(self, key, form_values):
        wx.PyEvent.__init__(self)
        self.SetEventType(wx_EVT_SET_PARAMETERS)
        self.key = key
        self.form_values = form_values

The main frame binds event handlers to EVT_SET_PARAMETERS, etc. To signal an event the thread creates an event instance of one of these classes and uses wx.PostEvent(window, evt) to post this to the main window.

I was expecting that the different events arriving at the main frame would get handled one at a time, as the documentation for wxPostEvent mentions that in a GUI application ([1]) this function actually calls AddPendingEvent on the window. However, I'm seeing that sometimes during the processing of an event by the main frame a handler for another event is called, i.e. events are getting handled simultaneously. Is this expected behaviour?

Regards,
Paul

[1] Are there any people using wxPython to NOT build a GUI application? :slight_smile: