Or you can remove this loop: while app.hasPendingEvents():
It's a harmless action.