'How to force event loop to continue processing events normally when the screen saver turns on

I just now encountered an unexpected and annoying behaviour of wxPython GUI on Mac. Although the effect makes sense when efficiency is concerned, right now it is hindering my application design. The app is ported from Windows where I didn't notice the said behaviour, but that might be because I disabled the screen saver there. What is happening is this: I have a wx.Timer() running every 80 MS. It triggers a function that, if certain conditions are met, switches focus from one wx.TextCtrl() to another and does some other GUI non-related things, among which is sending the value of the focused TextCtrl() to a TTS engine. However, after the screen saver appears, the wx.Timer() is triggered with big gaps between each event. The pauses grow in length the longer the computer is idle.

I don't know whether this is wx's built-in behaviour or a result of it using the OS's native application loop to process events, thus allowing the scheduler to dictate applications priority etc. In any case, I expect that it is possible to control this by overriding some methods in wx.App() or something similar. Otherwise I'll need to force the screen saver not to activate while my application is running or to use threads instead of wx.Timer() which then introduces other problems to be solved. Does anyone know how to easily solve this problem?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source