Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
5146154
Add gevent to requirements (#6369)
nzlosh Feb 19, 2026
75af8a3
wsgi WIP
skiedude Feb 24, 2026
020539c
Add gevent to pants requirements and regenerate lock file.
nzlosh Feb 19, 2026
f8c1a79
Move explicit eventlet calls behind concurrency module in auth.
nzlosh Feb 19, 2026
c07cc1f
Move blocking detection to concurrency module + black format
nzlosh Mar 1, 2026
cbf2e2d
Move wsgi behind concurrency library.
nzlosh Mar 6, 2026
5052875
more helpers in concurrency, migrate all files to use concurrency, up…
skiedude Mar 26, 2026
c7ad658
bump circleci version to 3.9
skiedude Mar 26, 2026
9d0ef6d
Merge upstream/master into eventlet_death
skiedude Jul 17, 2026
6e12760
Compile/Lint fixes
skiedude Jul 20, 2026
2ca0d53
compile/lint updates
skiedude Jul 22, 2026
7bcd1b7
feat(concurrency): make gevent a real drop-in replacement for eventlet
skiedude Aug 12, 2026
3072842
test: explicitly set concurrency_library in test conf files
skiedude Aug 12, 2026
62637e0
style: apply black formatting to test_gunicorn_configs.py
skiedude Aug 12, 2026
31408bb
Merge upstream/master into eventlet_death
skiedude Aug 12, 2026
57a1030
fix(concurrency): guarantee monkey patching before tooz import; simpl…
skiedude Aug 13, 2026
8f2de5f
style: black formatting fix for concurrency.py
skiedude Aug 13, 2026
0895139
fix(concurrency): wrap remaining direct kill/link/spawn/resize bypasses
skiedude Aug 19, 2026
1ecee25
Add CHANGELOG entry for gevent support
skiedude Aug 20, 2026
4f62da3
Update CHANGELOG entry with author and PR reference
skiedude Aug 20, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Changelog

in development
--------------
* Added support for gevent to replace eventlet. Going forward, the default will be gevent, and can be overriden in the conf file `system.concurrency_library = gevent|eventlet` @jzufelt #6372

* implemented zstandard compression for parameters and results. #5995
contributed by @guzzijones12

Expand Down
108 changes: 32 additions & 76 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,6 @@ install-runners:
@echo ""
# NOTE: We use xargs to speed things up by installing runners in parallel
echo -e "$(COMPONENTS_RUNNERS)" | tr -d "\n" | xargs -P $(XARGS_CONCURRENCY) -d " " -n1 -i bash -c "set -x; . $(VIRTUALENV_DIR)/bin/activate; cd $$(pwd)/{} ; $(PYBIN) -m pip install --editable . --no-deps"
#@for component in $(COMPONENTS_RUNNERS); do \
# echo "==========================================================="; \
# echo "Installing runner:" $$component; \
# echo "==========================================================="; \
# #(. $(VIRTUALENV_DIR)/bin/activate; cd $$component; python -m pip install --editable . --no-deps); \
#done

.PHONY: install-mock-runners
install-mock-runners:
Expand All @@ -198,12 +192,6 @@ install-mock-runners:
@echo ""
# NOTE: We use xargs to speed things up by installing runners in parallel
echo -e "$(MOCK_RUNNERS)" | tr -d "\n" | xargs -P $(XARGS_CONCURRENCY) -d " " -n1 -i sh -c ". $(VIRTUALENV_DIR)/bin/activate; cd $$(pwd)/{} ; $(PYBIN) -m pip install --editable . --no-deps"
#@for component in $(MOCK_RUNNERS); do \
# echo "==========================================================="; \
# echo "Installing mock runner:" $$component; \
# echo "==========================================================="; \
# (. $(VIRTUALENV_DIR)/bin/activate; cd $$component; python -m pip install --editable . --no-deps); \
#done

.PHONY: check-requirements
.check-requirements:
Expand Down Expand Up @@ -262,12 +250,12 @@ check-python-packages:
@echo "================== CHECK PYTHON PACKAGES ===================="
@echo ""
test -f $(VIRTUALENV_COMPONENTS_DIR)/bin/activate || $(PYBIN) -m venv $(VIRTUALENV_COMPONENTS_DIR) --system-site-packages
$(VIRTUALENV_COMPONENTS_DIR)/bin/pip install --quiet "setuptools==$(SETUPTOOLS_VERSION)"
$(VIRTUALENV_COMPONENTS_DIR)/bin/pip install --quiet "setuptools==$(SETUPTOOLS_VERSION)" setuptools_scm
@for component in $(COMPONENTS_WITHOUT_ST2TESTS); do \
echo "==========================================================="; \
echo "Checking component:" $$component; \
echo "==========================================================="; \
(set -e; cd $$component; ../$(VIRTUALENV_COMPONENTS_DIR)/bin/$(PYBIN) setup.py --version) || exit 1; \
(set -e; cd $$component; ../$(VIRTUALENV_COMPONENTS_DIR)/bin/$(PYBIN) -m setuptools_scm) || exit 1; \
done

.PHONY: check-python-packages-nightly
Expand All @@ -279,13 +267,13 @@ check-python-packages-nightly:
@echo ""

test -f $(VIRTUALENV_COMPONENTS_DIR)/bin/activate || $(PYBIN) -m venv $(VIRTUALENV_COMPONENTS_DIR) --system-site-packages
$(VIRTUALENV_COMPONENTS_DIR)/bin/pip install --quiet "setuptools==$(SETUPTOOLS_VERSION)" wheel
$(VIRTUALENV_COMPONENTS_DIR)/bin/pip install --quiet "setuptools==$(SETUPTOOLS_VERSION)" setuptools_scm wheel
@for component in $(COMPONENTS_WITHOUT_ST2TESTS); do \
echo "==========================================================="; \
echo "Checking component:" $$component; \
echo "==========================================================="; \
(set -e; cd $$component; ../$(VIRTUALENV_COMPONENTS_DIR)/bin/$(PYBIN) setup.py --version) || exit 1; \
(set -e; cd $$component; ../$(VIRTUALENV_COMPONENTS_DIR)/bin/$(PYBIN) setup.py sdist bdist_wheel) || exit 1; \
(set -e; cd $$component; ../$(VIRTUALENV_COMPONENTS_DIR)/bin/$(PYBIN) -m setuptools_scm) || exit 1; \
(set -e; cd $$component; ../$(VIRTUALENV_COMPONENTS_DIR)/bin/$(PYBIN) -m build) || exit 1; \
(set -e; cd $$component; ../$(VIRTUALENV_COMPONENTS_DIR)/bin/$(PYBIN) -m pip install --editable . --no-deps) || exit 1; \
($(VIRTUALENV_COMPONENTS_DIR)/bin/$(PYBIN) -c "import $$component") || exit 1; \
(set -e; cd $$component; rm -rf dist/; rm -rf $$component.egg-info) || exit 1; \
Expand Down Expand Up @@ -662,13 +650,6 @@ distclean: clean
scripts/write-headers.sh $$component/dist_utils.py || break;\
done

# Copy over CHANGELOG.RST, CONTRIBUTING.RST and LICENSE file to each component directory
#@for component in $(COMPONENTS_TEST); do\
# test -s $$component/README.rst || cp -f README.rst $$component/; \
# cp -f CONTRIBUTING.rst $$component/; \
# cp -f LICENSE $$component/; \
#done

.PHONY: .requirements
.requirements: virtualenv
$(VIRTUALENV_DIR)/bin/$(PYBIN) -m pip install --upgrade "pip==$(PIP_VERSION)"
Expand All @@ -681,16 +662,10 @@ distclean: clean
# Remove any *.egg-info files which polute PYTHONPATH
rm -rf *.egg-info*

# Generate finall requirements.txt file for each component
# Generate final requirements.txt file for each component
# NOTE: We use xargs to speed things up by running commands in parallel
echo -e "$(COMPONENTS_WITH_RUNNERS)" | tr -d "\n" | xargs -P $(XARGS_CONCURRENCY) -d " " -n1 -i sh -c "$(VIRTUALENV_DIR)/bin/$(PYBIN) scripts/fixate-requirements.py --skip=virtualenv,virtualenv-osx -s {}/in-requirements.txt -f fixed-requirements.txt -o {}/requirements.txt"

#@for component in $(COMPONENTS_WITH_RUNNERS); do\
# echo "==========================================================="; \
# echo "Generating requirements.txt for" $$component; \
# $(VIRTUALENV_DIR)/bin/python scripts/fixate-requirements.py --skip=virtualenv,virtualenv-osx -s $$component/in-requirements.txt -f fixed-requirements.txt -o $$component/requirements.txt; \
#done

@echo "==========================================================="

.PHONY: requirements
Expand Down Expand Up @@ -781,21 +756,6 @@ endif
echo 'export PYTHONPATH' >> $(VIRTUALENV_DIR)/bin/activate
touch $(VIRTUALENV_DIR)/bin/activate

# Setup PYTHONPATH in fish activate script...
#echo '' >> $(VIRTUALENV_DIR)/bin/activate.fish
#echo 'set -gx _OLD_PYTHONPATH $$PYTHONPATH' >> $(VIRTUALENV_DIR)/bin/activate.fish
#echo 'set -gx PYTHONPATH $$_OLD_PYTHONPATH $(COMPONENT_PYTHONPATH)' >> $(VIRTUALENV_DIR)/bin/activate.fish
#echo 'functions -c deactivate old_deactivate' >> $(VIRTUALENV_DIR)/bin/activate.fish
#echo 'function deactivate' >> $(VIRTUALENV_DIR)/bin/activate.fish
#echo ' if test -n $$_OLD_PYTHONPATH' >> $(VIRTUALENV_DIR)/bin/activate.fish
#echo ' set -gx PYTHONPATH $$_OLD_PYTHONPATH' >> $(VIRTUALENV_DIR)/bin/activate.fish
#echo ' set -e _OLD_PYTHONPATH' >> $(VIRTUALENV_DIR)/bin/activate.fish
#echo ' end' >> $(VIRTUALENV_DIR)/bin/activate.fish
#echo ' old_deactivate' >> $(VIRTUALENV_DIR)/bin/activate.fish
#echo ' functions -e old_deactivate' >> $(VIRTUALENV_DIR)/bin/activate.fish
#echo 'end' >> $(VIRTUALENV_DIR)/bin/activate.fish
#touch $(VIRTUALENV_DIR)/bin/activate.fish

# debug pip installed packages
$(VIRTUALENV_DIR)/bin/pip list

Expand Down Expand Up @@ -867,7 +827,7 @@ endif
@echo
@echo "----- Dropping st2-test db -----"
@mongosh st2-test --eval "db.dropDatabase();"
failed=0; \
failed=(); \
for component in $(COMPONENTS_TEST); do\
echo "==========================================================="; \
echo "Running tests in" $$component; \
Expand All @@ -878,13 +838,13 @@ endif
ST2TESTS_REDIS_PORT=$(ST2TESTS_REDIS_PORT) \
COVERAGE_FILE=.coverage.unit.$$(echo $$component | tr '/' '.') \
pytest --verbose $(PYTEST_OPTS) --cov=$$component --cov-branch \
$$component/tests/unit || ((failed+=1)); \
$$component/tests/unit || failed+=($$component); \
echo "-----------------------------------------------------------"; \
echo "Done running tests in" $$component; \
echo "==========================================================="; \
done; \
echo pytest runs failed=$$failed; \
if [ $$failed -gt 0 ]; then exit 1; fi
echo "pytest runs failed=$${failed[@]}"; \
if [ $${#failed[@]} -gt 0 ]; then exit 1; fi

.PHONY: .combine-unit-tests-coverage
.combine-unit-tests-coverage: .run-unit-tests-coverage
Expand Down Expand Up @@ -929,21 +889,21 @@ itests: requirements .itests
@echo
@echo "----- Dropping st2-test db -----"
@mongosh st2-test --eval "db.dropDatabase();"
@failed=0; \
@failed=(); \
for component in $(COMPONENTS_TEST); do\
echo "==========================================================="; \
echo "Running integration tests in" $$component; \
echo "-----------------------------------------------------------"; \
. $(VIRTUALENV_DIR)/bin/activate; \
EVENTLET_TESTS=1 \
pytest --capture=no --verbose $(PYTEST_OPTS) \
$$component/tests/integration || ((failed+=1)); \
$$component/tests/integration || failed+=($$component); \
echo "-----------------------------------------------------------"; \
echo "Done running integration tests in" $$component; \
echo "==========================================================="; \
done; \
echo pytest runs failed=$$failed; \
if [ $$failed -gt 0 ]; then exit 1; fi
echo "pytest runs failed=$${failed[@]}"; \
if [ $${#failed[@]} -gt 0 ]; then exit 1; fi

.PHONY: .run-integration-tests-coverage
ifdef INCLUDE_TESTS_IN_COVERAGE
Expand All @@ -955,7 +915,7 @@ endif
@echo
@echo "----- Dropping st2-test db -----"
@mongosh st2-test --eval "db.dropDatabase();"
@failed=0; \
@failed=(); \
for component in $(COMPONENTS_TEST); do\
echo "==========================================================="; \
echo "Running integration tests in" $$component; \
Expand All @@ -964,13 +924,13 @@ endif
EVENTLET_TESTS=1 \
COVERAGE_FILE=.coverage.integration.$$(echo $$component | tr '/' '.') \
pytest --capture=no --verbose $(PYTEST_OPTS) --cov=$$component --cov-branch \
$$component/tests/integration || ((failed+=1)); \
$$component/tests/integration || failed+=($$component); \
echo "-----------------------------------------------------------"; \
echo "Done integration running tests in" $$component; \
echo "==========================================================="; \
done; \
echo pytest runs failed=$$failed; \
if [ $$failed -gt 0 ]; then exit 1; fi
echo "pytest runs failed=$${failed[@]}"; \
if [ $${#failed[@]} -gt 0 ]; then exit 1; fi
# NOTE: If you also want to run orquesta tests which seem to have a bunch of race conditions, use
# ci-integration-full target
# @echo
Expand Down Expand Up @@ -1039,13 +999,6 @@ endif
make .coverage-combine; \
fi

# @for coverage_result in $(COVERAGE_GLOBS); do \
# [ -e $${coverage_result} ] || echo "$${coverage_result} does not exist." && continue; \
# echo "Combining data from $${coverage_result}"; \
# . $(VIRTUALENV_DIR)/bin/activate; coverage combine $${coverage_result}; \
# done || \
# (echo "Running .coverage-combine"; make .coverage-combine)

.PHONY: .coverage-report
.coverage-report: .coverage
. $(VIRTUALENV_DIR)/bin/activate; coverage report
Expand Down Expand Up @@ -1096,14 +1049,16 @@ runners-tests: requirements .runners-tests
@echo
@echo "----- Dropping st2-test db -----"
@mongosh st2-test --eval "db.dropDatabase();"
@failed=0; \
@failed=(); \
for component in $(COMPONENTS_RUNNERS); do\
echo "==========================================================="; \
echo "Running tests in" $$component; \
echo "==========================================================="; \
. $(VIRTUALENV_DIR)/bin/activate; pytest --capture=no --verbose $(PYTEST_OPTS) $$component/tests/unit || ((failed+=1)); \
. $(VIRTUALENV_DIR)/bin/activate; \
pytest --capture=no --verbose $(PYTEST_OPTS) $$component/tests/unit || failed+=($$component); \
done; \
if [ $$failed -gt 0 ]; then exit 1; fi
echo "pytest runs failed=$${failed[@]}"; \
if [ $${#failed[@]} -gt 0 ]; then exit 1; fi

.PHONY: runners-itests
runners-itests: requirements .runners-itests
Expand All @@ -1114,32 +1069,33 @@ runners-itests: requirements .runners-itests
@echo "==================== runners-itests ===================="
@echo
@echo "----- Dropping st2-test db -----"
@failed=0; \
@failed=(); \
for component in $(COMPONENTS_RUNNERS); do\
echo "==========================================================="; \
echo "Running integration tests in" $$component; \
echo "==========================================================="; \
. $(VIRTUALENV_DIR)/bin/activate; pytest --capture=no --verbose $(PYTEST_OPTS) $$component/tests/integration || ((failed+=1)); \
. $(VIRTUALENV_DIR)/bin/activate; \
pytest --capture=no --verbose $(PYTEST_OPTS) $$component/tests/integration || failed+=($$component); \
done; \
echo pytest runs failed=$$failed; \
if [ $$failed -gt 0 ]; then exit 1; fi
echo "pytest runs failed=$${failed[@]}"; \
if [ $${#failed[@]} -gt 0 ]; then exit 1; fi

.PHONY: .runners-itests-coverage-html
.runners-itests-coverage-html:
@echo
@echo "============== runners-itests-coverage-html =============="
@echo
@echo "The tests assume st2 is running on 127.0.0.1."
@failed=0; \
@failed=(); \
for component in $(COMPONENTS_RUNNERS); do\
echo "==========================================================="; \
echo "Running integration tests in" $$component; \
echo "==========================================================="; \
. $(VIRTUALENV_DIR)/bin/activate; pytest --capture=no --verbose $(PYTEST_OPTS) \
--cov=$$component --cov-report=html $$component/tests/integration || ((failed+=1)); \
--cov=$$component --cov-report=html $$component/tests/integration || failed+=($$component); \
done; \
echo pytest runs failed=$$failed; \
if [ $$failed -gt 0 ]; then exit 1; fi
echo "pytest runs failed=$${failed[@]}"; \
if [ $${#failed[@]} -gt 0 ]; then exit 1; fi

.PHONY: cli
cli:
Expand Down
3 changes: 3 additions & 0 deletions conf/st2.conf.sample
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,9 @@ protocol = udp
[system]
# Base path to all st2 artifacts.
base_path = /opt/stackstorm
# Green thread concurrency library to use ('eventlet' or 'gevent'). NOTE: This is read directly from this config file at process startup, before oslo_config is available, so it cannot be overridden via CLI args or environment variables.
# Valid values: eventlet, gevent
concurrency_library = gevent
# Enable debug mode.
debug = False
# True to validate action and runner output against schema.
Expand Down
1 change: 1 addition & 0 deletions conf/st2.tests.conf
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ api_url = http://127.0.0.1:9101/
[system]
# This way integration tests can write to this directory
base_path = /tmp
concurrency_library = gevent

[garbagecollector]
logging = st2reactor/conf/logging.garbagecollector.conf
Expand Down
10 changes: 10 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@
import hashlib
from typing import Iterable, List, Sequence

# NOTE: This must happen before any test module imports anything that pulls in tooz/eventlet
# (e.g. st2common.services.coordination). Tooz's Heart binds threading.Thread/Event as default
# args at import time, so if it's imported before monkey patching, it permanently uses the
# unpatched primitives -- causing gevent.exceptions.LoopExit or hangs later. Pytest always loads
# this file before any test module, in both whole-directory and single-file (Pants) runs, so this
# is the one place that reliably wins the race regardless of which test file happens to run first.
from st2common.util.monkey_patch import monkey_patch

monkey_patch()

from _pytest import nodes
from _pytest.config import create_terminal_writer

Expand Down
4 changes: 2 additions & 2 deletions contrib/examples/actions/python-mock-create-vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import eventlet
import random

from st2common.runners.base_action import Action
from st2common.util import concurrency


class MockCreateVMAction(Action):
def run(self, cpu_cores, memory_mb, vm_name, ip):
eventlet.sleep(5)
concurrency.sleep(5)

data = {
"vm_id": "vm" + str(random.randint(0, 10000)),
Expand Down
5 changes: 2 additions & 3 deletions contrib/hello_st2/sensors/sensor1.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import eventlet

from st2common.util import concurrency
from st2reactor.sensor.base import Sensor


Expand All @@ -34,7 +33,7 @@ def run(self):
payload = {"greeting": "Yo, StackStorm!", "count": int(count) + 1}
self.sensor_service.dispatch(trigger="hello_st2.event1", payload=payload)
self.sensor_service.set_value("hello_st2.count", payload["count"])
eventlet.sleep(60)
concurrency.sleep(60)

def cleanup(self):
self._stop = True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

from __future__ import absolute_import

import eventlet
import traceback
import uuid
import datetime
Expand All @@ -24,6 +23,7 @@
from jsonschema import exceptions as json_schema_exc
from oslo_config import cfg

from st2common.util import concurrency
from st2common.runners.base import ActionRunner
from st2common.runners.base import get_metadata as get_runner_metadata
from st2common import log as logging
Expand Down Expand Up @@ -879,7 +879,7 @@ def _run_action(self, liveaction, wait_for_completion=True, sleep_delay=1.0):
action_constants.LIVEACTION_STATUS_PENDING,
]
):
eventlet.sleep(sleep_delay)
concurrency.sleep(sleep_delay)
liveaction = action_db_util.get_liveaction_by_id(liveaction.id)

return liveaction
Expand All @@ -901,7 +901,7 @@ def _resume_action(self, liveaction, wait_for_completion=True, sleep_delay=1.0):
action_constants.LIVEACTION_COMPLETED_STATES
+ [action_constants.LIVEACTION_STATUS_PAUSED]
):
eventlet.sleep(sleep_delay)
concurrency.sleep(sleep_delay)
liveaction = action_db_util.get_liveaction_by_id(liveaction.id)

return liveaction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def test_chain_runner_bad_default(self, request):
runnerexceptions.ActionRunnerPreRunError, expected_msg, chain_runner.pre_run
)

@mock.patch("eventlet.sleep", mock.MagicMock())
@mock.patch("st2common.util.concurrency.sleep", mock.MagicMock())
@mock.patch.object(
action_db_util,
"get_liveaction_by_id",
Expand Down
Loading
Loading