diff --git a/tests/deadlocks/main.py b/tests/deadlocks/main.py new file mode 100644 index 0000000000..66e3b37ddf --- /dev/null +++ b/tests/deadlocks/main.py @@ -0,0 +1,4 @@ +def application(env, start_response): + start_response("200 OK", [("Content-Type", "text/plain")]) + message = "Hello World" + return [message.encode("utf-8")] diff --git a/tests/deadlocks/master-nothreads.ini b/tests/deadlocks/master-nothreads.ini new file mode 100644 index 0000000000..e922e5ef23 --- /dev/null +++ b/tests/deadlocks/master-nothreads.ini @@ -0,0 +1,5 @@ +[uwsgi] +show-config = true +master = true +enable-threads = false +workers = 1 diff --git a/tests/deadlocks/master-singleinterpreter-threads-10workers.ini b/tests/deadlocks/master-singleinterpreter-threads-10workers.ini new file mode 100644 index 0000000000..d97c74522a --- /dev/null +++ b/tests/deadlocks/master-singleinterpreter-threads-10workers.ini @@ -0,0 +1,6 @@ +[uwsgi] +show-config = true +master = true +enable-threads = true +workers = 10 +single-interpreter = true diff --git a/tests/deadlocks/master-singleinterpreter-threads-1worker.ini b/tests/deadlocks/master-singleinterpreter-threads-1worker.ini new file mode 100644 index 0000000000..a282ae4071 --- /dev/null +++ b/tests/deadlocks/master-singleinterpreter-threads-1worker.ini @@ -0,0 +1,6 @@ +[uwsgi] +show-config = true +master = true +enable-threads = true +workers = 1 +single-interpreter = true diff --git a/tests/deadlocks/master-threads-10workers.ini b/tests/deadlocks/master-threads-10workers.ini new file mode 100644 index 0000000000..27e8f08921 --- /dev/null +++ b/tests/deadlocks/master-threads-10workers.ini @@ -0,0 +1,5 @@ +[uwsgi] +show-config = true +master = true +enable-threads = true +workers = 10 diff --git a/tests/deadlocks/master-threads-1worker.ini b/tests/deadlocks/master-threads-1worker.ini new file mode 100644 index 0000000000..f4dd9605ce --- /dev/null +++ b/tests/deadlocks/master-threads-1worker.ini @@ -0,0 +1,5 @@ +[uwsgi] +show-config = true +master = true +enable-threads = true +workers = 1 diff --git a/tests/deadlocks/nomaster-threads-10workers.ini b/tests/deadlocks/nomaster-threads-10workers.ini new file mode 100644 index 0000000000..38cfe23b7a --- /dev/null +++ b/tests/deadlocks/nomaster-threads-10workers.ini @@ -0,0 +1,5 @@ +[uwsgi] +show-config = true +master = false +enable-threads = true +workers = 10 diff --git a/tests/deadlocks/nomaster-threads-1worker.ini b/tests/deadlocks/nomaster-threads-1worker.ini new file mode 100644 index 0000000000..eeb4e544c5 --- /dev/null +++ b/tests/deadlocks/nomaster-threads-1worker.ini @@ -0,0 +1,5 @@ +[uwsgi] +show-config = true +master = false +enable-threads = true +workers = 1 diff --git a/tests/deadlocks/sitecustomize.py b/tests/deadlocks/sitecustomize.py new file mode 100644 index 0000000000..0aff259f7b --- /dev/null +++ b/tests/deadlocks/sitecustomize.py @@ -0,0 +1,14 @@ +import threading +import time + + +def run(): + print("[DEADLOCKS] started run") + st = time.time() + while time.time() < st + 5: + pass + print("[DEADLOCKS] finished run") + +t = threading.Thread(target=run) +t.daemon = True +t.start() diff --git a/tests/travis.sh b/tests/travis.sh index a8b54fe1c3..c9db45df2e 100755 --- a/tests/travis.sh +++ b/tests/travis.sh @@ -69,6 +69,20 @@ test_python() { } +test_python_deadlocks() { + date > reload.txt + rm -f uwsgi.log + echo -e "${bldyel}================== TESTING DEADLOCKS $1 $2 =====================${txtrst}" + echo -e "${bldyel}>>> Starting python app${txtrst}" + echo -en "${bldred}" + # initialize with tests/deadlocks/sitecustomize.py + PYTHONPATH=tests/deadlocks ./uwsgi --plugin 0:$1 --http :8080 --exit-on-reload --touch-reload reload.txt --wsgi-file tests/deadlocks/main.py --ini $2 --daemonize uwsgi.log + echo -en "${txtrst}" + http_test "http://localhost:8080/" + echo -e "${bldyel}===================== DONE $1 $2 =====================${txtrst}\n\n" +} + + test_rack() { date > reload.txt rm -f uwsgi.log @@ -90,8 +104,11 @@ while read PV ; do test_python $PV $WSGI_FILE done done < <(cat "$CI_CONFIG" | grep "plugins/python base" | sed s_".*plugins/python base "_""_g) - - +while read PV ; do + for INI_FILE in tests/deadlocks/*.ini ; do + test_python_deadlocks $PV $INI_FILE + done +done < <(cat "$CI_CONFIG" | grep "plugins/python base" | sed s_".*plugins/python base "_""_g) while read RV ; do for RACK in examples/config2.ru ; do test_rack $RV $RACK