def _runInMainThread(self, f): """ Schedule function to run in main wx/Twisted thread. Called by the select() thread. """ if hasattr(self, "wxapp"): wxCallAfter(f) else: # wx shutdown but twisted hasn't self._postQueue.put(f)