You’ll need to be mindful of flushing the buffer
You might be able to set this environment variable to make sure there’s no annoying output buffer:
PYTHONUNBUFFERED=true
In python that would be
import os
os.environ['PYTHONUNBUFFERED'] = True
Haven’t tried it but worth a go - do it once and you can forget about it. Anvil’s Server Modules are python processes running in a carefully-security-engineered *nix environment, so you can do this sort of thing!