Consistent way to suppress solver output

Had some trouble with this where output was still printed.
It was due to the C level output not being flushed before the stdout gets restored.
So might be helpful to call :

Base.Libc.flush_cstdio()

Can use the following to print to a file as well :

open("/dev/null", "w") do f
    redirect_stdout(f) do
    # redirect_stdio(stdout=f,stderr=f) do
        optimize!(model)
        Base.Libc.flush_cstdio()
    end
end
2 Likes