In the original version, if racer does not exist, the call to racer Popen(cmd_list, stdout=PIPE, stderr=PIPE, env=env, startupinfo=startupinfo) will raise a FileNotFoundError and get caught by upper caller on_query_completions.
The problem here is, once the error is raised, run_racer returns immediately and skipped os.remove(temp_file_path), therefore the temporary file doesn't get deleted and piles up.
In the original version, if racer does not exist, the call to racer
Popen(cmd_list, stdout=PIPE, stderr=PIPE, env=env, startupinfo=startupinfo)
will raise aFileNotFoundError
and get caught by upper calleron_query_completions
.The problem here is, once the error is raised,
run_racer
returns immediately and skippedos.remove(temp_file_path)
, therefore the temporary file doesn't get deleted and piles up.Screenshot: tmp files can't get cleaned
By checking the existence of racer before any work begins, we can avoid the creation of temp files