Tests - Don't hang if spawning taskw fails
This commit is contained in:
@@ -108,7 +108,20 @@ def _queue_output(arguments, pidq, outputq):
|
|||||||
kwargs = arguments["process"]
|
kwargs = arguments["process"]
|
||||||
input = arguments["input"]
|
input = arguments["input"]
|
||||||
|
|
||||||
proc = Popen(**kwargs)
|
try:
|
||||||
|
proc = Popen(**kwargs)
|
||||||
|
except OSError as e:
|
||||||
|
# pid None is read by the main thread as a crash of the process
|
||||||
|
pidq.put(None)
|
||||||
|
|
||||||
|
outputq.put((
|
||||||
|
"",
|
||||||
|
("Unexpected exception caught during execution of taskw: '{0}' . "
|
||||||
|
"If you are running out-of-tree tests set USE_PATH=1 in shell "
|
||||||
|
"env before execution".format(e)),
|
||||||
|
255)) # false exitcode
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
# NOTE If for whatever reason pid is None at the time of access, use the
|
# NOTE If for whatever reason pid is None at the time of access, use the
|
||||||
# following line instead
|
# following line instead
|
||||||
@@ -161,6 +174,10 @@ def _get_output(arguments, timeout=None):
|
|||||||
try:
|
try:
|
||||||
pid = pidq.get(timeout=timeout)
|
pid = pidq.get(timeout=timeout)
|
||||||
except Empty:
|
except Empty:
|
||||||
|
pid = None
|
||||||
|
|
||||||
|
# Process crashed or timed out for some reason
|
||||||
|
if pid is None:
|
||||||
return _retrieve_output(t, output_timeout, outputq,
|
return _retrieve_output(t, output_timeout, outputq,
|
||||||
"TaskWarrior to start")
|
"TaskWarrior to start")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user