I have faced similar issues few years back, I have realised this due to Python buffering.
You can disable output buffering by running python script with -u option.
python -u your_script.py
Or you can set the environment variable PYTHONUNBUFFERED=1 to make python run in unbuffered mode.