I want to run application in production with coverage enable. The application is always up and do not stop its execution. In each day I want to see coverage increase. Unfortunately .coverage file appear on the disk only after application stop.
To simulate this behavior I have test.py
# cat test.py
if 1==2:
print(1)
if 2==2:
print(2)
import time
i = 10
while i:
print("sleep")
time.sleep(1)
i -= 1
print("end")
Which is launched like
python3 -u -m coverage run test.py
2
sleep
sleep
sleep
sleep # I want to be able to see coverage in this moment
sleep
sleep
sleep
sleep
sleep
sleep
end
Only after end word is printed I can see coverage file
ls -a
. .. .coverage test.py
How can I force flushing/Unbuffering on py.coverage ?