You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Run a subprocess. Send commands and receive structured output.
31
+
Create new object, along with subprocess
32
+
33
+
Args:
34
+
command: Command to run in shell to spawn new subprocess
35
+
time_to_check_for_additional_output_sec: When parsing responses, wait this amout of time before exiting (exits before timeout is reached to save time). If <= 0, full timeout time is used.
36
+
Returns:
37
+
New ProcessController object
38
+
"""
39
+
40
+
ifcommandisNone:
41
+
command=DEFAULT_PROCESS_LAUNCH_COMMAND
42
+
43
+
# if not any([("--interpreter=mi" in c) for c in command]):
44
+
# logger.warning(
45
+
# "warning. "
46
+
# )
47
+
self.abs_app_path=None# abs path to executable
48
+
self.command=command# type: List[str]
49
+
self.time_to_check_for_additional_output_sec= (
50
+
time_to_check_for_additional_output_sec
51
+
)
52
+
self.app_process=None
53
+
self._allow_overwrite_timeout_times= (
54
+
self.time_to_check_for_additional_output_sec>0
55
+
)
56
+
app_path=command.split(' ')[0]
57
+
58
+
ifnotapp_path:
59
+
raiseValueError("a valid path to app must be specified")
60
+
61
+
else:
62
+
abs_app_path=find_executable(app_path)
63
+
ifabs_app_pathisNone:
64
+
raiseValueError(
65
+
'executable could not be resolved from "%s"'%app_path
66
+
)
67
+
68
+
else:
69
+
self.abs_app_path=abs_app_path
70
+
self.spawn_new_subprocess()
71
+
72
+
defspawn_new_subprocess(self):
73
+
"""Spawn a new subprocess with the arguments supplied to the object
74
+
during initialization. If subprocess already exists, terminate it before
75
+
spanwing a new one.
76
+
Return int: process id
77
+
"""
78
+
ifself.app_process:
79
+
logger.debug(
80
+
"Killing current subprocess (pid %d)"%self.app_process.pid
0 commit comments