The VBA "DoEvents" function can be called from a VBA macro to temporarily yield back to Excel. This is used to allow Excel to process keyboard, mouse and other event messages. In long running macros Excel can appear unresponsive and Excel appears to freeze. This is because while the macro is running Excel is not processing any events or updating, and calling DoEvents in VBA periodically gives it a chance to update.
In Python the same thing happens. When running a Python Excel macro, the Excel message loop will not run as it is blocked by the running Python macro. In order to let Excel's message loop process any pending messages call pythoncom.PumpWaitingMessages(). This will have the same effect as calling DoEvents in VBA.
import pythoncom
pythoncom.PumpWaitingMessages()
If you don't have the pythoncom package you can install it using pip or conda.
pip install pywin32