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
[Bug] 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
#13435
I had searched in the issues 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
bugSomething isn't working and you are sure it's a bug!
1 participant
Converted from issue
This discussion was converted from issue #13434 on August 20, 2025 06:44.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Search before asking
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)
@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?
Code of Conduct
Beta Was this translation helpful? Give feedback.
All reactions