-
Notifications
You must be signed in to change notification settings - Fork 452
agent spawn child subprocess not grandchild #2583
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -378,7 +378,7 @@ def get_subprocess_status(): | |
"""Return the subprocess status.""" | ||
async_subprocess = state.get("async_subprocess") | ||
message = "Analysis status" | ||
exitcode = async_subprocess.exitcode | ||
exitcode = async_subprocess.poll() | ||
if exitcode is None or (sys.platform == "win32" and exitcode == 259): | ||
# Process is still running. | ||
state["status"] = Status.RUNNING | ||
|
@@ -713,9 +713,7 @@ def background_subprocess(command_args, cwd, base64_encode, shell=False): | |
|
||
def spawn(args, cwd, base64_encode, shell=False): | ||
"""Kick off a subprocess in the background.""" | ||
run_subprocess_args = [args, cwd, base64_encode, shell] | ||
proc = multiprocessing.Process(target=background_subprocess, name=f"child process {args[1]}", args=run_subprocess_args) | ||
proc.start() | ||
proc = subprocess.Popen(args, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=shell) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider adding error handling for the try:
proc = subprocess.Popen(args, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=shell)
except Exception as e:
state["status"] = Status.FAILED
state["description"] = f"Failed to start subprocess: {e}"
return json_error(500, f"Failed to start subprocess: {e}") |
||
state["status"] = Status.RUNNING | ||
state["description"] = "" | ||
state["async_subprocess"] = proc | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a comment explaining why
poll()
is used instead ofexitcode
here. Also, it might be good to check ifpoll()
is the right method for all platforms.