QtWebEngine: Be careful when doing periodic WebChannel requests

Today I had to resolve a mysterious bug in a PyQt5 / QtWebEngine application. After the user unlocked his session, the application hangs for a while before resuming to normal activity. I've added an JavaScript interval that prints the current time once a second onto the console, but even through the timestamps were OK it seems that something had freezed the application while the screen was locked.

To make it short, the application requested a status update via WebChannel once a second. While the Javascript kept active, the event loop of QApplication was blocked, so that the WebChannel events were put into a queue. (The reason for the block was the change to a new VT by the light-locker lock screen - I was able emulate it by manually switching to VT1 after the application has been started). When the application got active again, Qt started to empty the queue before any new events were processed.

My solution was to omit the periodic status updates when the webchannel isn't idle.