Open grabear opened 5 years ago
What if we actually got an error in the system_r_call? i.e. stdout is not actually the information we want. We should handle that.
Originally posted by @santina in https://github.com/datasnakes/renv/pull/42
I think with the proc.communicate
function it's typically best to use the TimeoutExpired
exception since that's the main thing that function depends on is a timeout.
However, you could do a bigger catch like...
try:
recommended_pkgs = sp.Popen([Rcmd], stderr=sp.PIPE, stdout=sp.PIPE,
shell=True, encoding='utf-8')
try:
stdout, stderr = recommended_pkgs.communicate(timeout=15)
except TimeoutExpired:
recommended_pkgs.kill()
stdout, stderr = recommended_pkgs.communicate()
return stdout, stderr
except subprocess.CalledProcessError as err:
# There was an error - command exited with non-zero code
logger.error(err)
It may be better to write functions for both.
Is this the only exception we might hit?
Originally posted by @santina in https://github.com/datasnakes/renv/pull/42