I have a weird behaviour using a Python application, (running under supervisor
), that relies on a C library to initialize a component.
My problem is that i cannot see the output printed by this C library when i call a function there.
All the output in the application is managed with the logging
module, and supervisor redirects it to a single log file.
So i thought this was just flush
problem, and I tried the following:
lib.init_func()
sys.stdout.flush()
sys.stderr.flush()
But it doesn't work. I cannot see my printf()
in the log file.
Also, I noticed that if i try to restart the application:
sudo supervisorctl restart all
The C library output gets finally flushed at the end of the log file !
Finally, setting PYTHONUNBUFFERED=1
in supervisorctl makes it works, but i don't want to run my program unbuffered for performance issues.
--> Can someone explain why using sys.stdout.flush()
after the call to the C library is not flushing it's output on my log file ?
Thanks !