try to flush everytime it's possible

Signed-off-by: Sebastien Varrette <sebastien.varrette@uni.lu>