@cevich What about add error type? I use try here because without it will report error "local variable 'tmp_file' referenced before assignment", that because variable tmp_file define in a if:else branch. I think it will still report error even if I use your way. Change to following:
try:
   os.remove(tmp_file)
except OSError:
    pass
is that ok?