yeqiangdu opened a new issue, #13434: URL: https://github.com/apache/skywalking/issues/13434
### Search before asking - [x] I had searched in the [issues](https://github.com/apache/skywalking/issues?q=is%3Aissue) and found no similar issues. ### Apache SkyWalking Component Python Agent (apache/skywalking-python) ### What happened When using gunicorn to start the service, subprocess.Popen executes the shell, and the python app-py file gets stuck and timeout occurs when running in the shell def run_shell_and_wait(cmd: str, wait_time=None): print(f"Running command: {cmd}") process = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) print(f"Waiting for command to finish with timeout: {wait_time}") exit_code = process.wait(timeout=wait_time) print(f"Command finished with exit code: {exit_code}") return exit_code !#/bin/sh echo "Running tests..." python $1 echo "Done." ### What you expected to happen import subprocess from flask import Flask, request, jsonify # import pydevd_pycharm # pydevd_pycharm.settrace('localhost', port=5678, stdout_to_server=True, stderr_to_server=True) app = Flask(__name__) def run_shell_and_wait(cmd: str, wait_time=None): print(f"Running command: {cmd}") process = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) print(f"Waiting for command to finish with timeout: {wait_time}") exit_code = process.wait(timeout=wait_time) print(f"Command finished with exit code: {exit_code}") return exit_code @app.route('/run-shell') def run_shell_command(): cmd = request.args.get('command') timeout = request.args.get('timeout', None, type=int) if not cmd: return jsonify({"error": "Missing 'command' parameter"}), 400 try: exit_code = run_shell_and_wait(cmd, timeout) return jsonify({ "status": "completed", "exit_code": exit_code, "message": f"Command executed with exit code {exit_code}" }) except Exception as e: return jsonify({"error": str(e)}), 500 @app.route('/health') def health_check(): return jsonify({"status": "healthy"}), 200 if __name__ == '__main__': app.run(host='0.0.0.0', port=8000, debug=True) ### How to reproduce sw-python run -p gunicorn -w 1 -b 0.0.0.0:8000 wsgi:app http://localhost:8000/run-shell?command=sh%20test.sh%20test.py ### Anything else _No response_ ### Are you willing to submit a pull request to fix on your own? - [ ] Yes I am willing to submit a pull request on my own! ### Code of Conduct - [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@skywalking.apache.org.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org