From d97487342aad0db30ea5903fb81284013ca15720 Mon Sep 17 00:00:00 2001 From: amanda Date: Mon, 19 Apr 2021 17:04:16 +0100 Subject: [PATCH 1/5] Stop hang when use mongo SSL --- st2stream/st2stream/app.py | 5 ----- st2stream/st2stream/wsgi.py | 2 ++ 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/st2stream/st2stream/app.py b/st2stream/st2stream/app.py index e61684b7bf..0235d1ad56 100644 --- a/st2stream/st2stream/app.py +++ b/st2stream/st2stream/app.py @@ -34,7 +34,6 @@ from st2common.middleware.instrumentation import RequestInstrumentationMiddleware from st2common.middleware.instrumentation import ResponseInstrumentationMiddleware from st2common.router import Router -from st2common.util.monkey_patch import monkey_patch from st2common.constants.system import VERSION_STRING from st2common.service_setup import setup as common_setup from st2common.util import spec_loader @@ -47,10 +46,6 @@ def setup_app(config={}): is_gunicorn = config.get("is_gunicorn", False) if is_gunicorn: - # Note: We need to perform monkey patching in the worker. If we do it in - # the master process (gunicorn_config.py), it breaks tons of things - # including shutdown - monkey_patch() st2stream_config.register_opts(ignore_errors=True) capabilities = { diff --git a/st2stream/st2stream/wsgi.py b/st2stream/st2stream/wsgi.py index 14d847e2a1..03da91382d 100644 --- a/st2stream/st2stream/wsgi.py +++ b/st2stream/st2stream/wsgi.py @@ -14,6 +14,8 @@ # limitations under the License. import os +from st2common.util.monkey_patch import monkey_patch +monkey_patch() from st2stream import app From c1a029672b9cc312d7fe9a557faf61e64010c647 Mon Sep 17 00:00:00 2001 From: amanda Date: Mon, 19 Apr 2021 17:19:53 +0100 Subject: [PATCH 2/5] Fix black --- st2stream/st2stream/wsgi.py | 1 + 1 file changed, 1 insertion(+) diff --git a/st2stream/st2stream/wsgi.py b/st2stream/st2stream/wsgi.py index 03da91382d..d9b3c9c5c0 100644 --- a/st2stream/st2stream/wsgi.py +++ b/st2stream/st2stream/wsgi.py @@ -15,6 +15,7 @@ import os from st2common.util.monkey_patch import monkey_patch + monkey_patch() from st2stream import app From ceefe7ab933024b31ee9e4006f7f542123f04690 Mon Sep 17 00:00:00 2001 From: Amanda McGuinness Date: Wed, 21 Apr 2021 22:27:57 +0100 Subject: [PATCH 3/5] Update CHANGELOG.rst --- CHANGELOG.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index a79a2b042a..f1cb81f45a 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -219,6 +219,10 @@ Changed Contributed by @chadpatt . +* Monkey patch on st2stream earlier in flow #5240 + + Contributed by Amanda McGuinness (@amanda11 Ammeon Solutions) + Improvements ~~~~~~~~~~~~ From ae326c936ebdcf9b2dbeba87a9ce4c04812ab84d Mon Sep 17 00:00:00 2001 From: Tomaz Muraus Date: Thu, 22 Apr 2021 13:06:52 +0200 Subject: [PATCH 4/5] Update wsgi.py Perform monkey patch as the very first thing - even before importing os module. --- st2stream/st2stream/wsgi.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/st2stream/st2stream/wsgi.py b/st2stream/st2stream/wsgi.py index d9b3c9c5c0..14c673a9ee 100644 --- a/st2stream/st2stream/wsgi.py +++ b/st2stream/st2stream/wsgi.py @@ -13,11 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os from st2common.util.monkey_patch import monkey_patch monkey_patch() +import os + from st2stream import app config = { From 2a71ff06ad773365383db5bb1186774ed5a9bfc6 Mon Sep 17 00:00:00 2001 From: Tomaz Muraus Date: Thu, 22 Apr 2021 13:09:08 +0200 Subject: [PATCH 5/5] Remove testing change, also run micro benchmarks under 3.8. --- .github/workflows/microbenchmarks.yaml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/microbenchmarks.yaml b/.github/workflows/microbenchmarks.yaml index e3a0b71ba3..72d050d38b 100644 --- a/.github/workflows/microbenchmarks.yaml +++ b/.github/workflows/microbenchmarks.yaml @@ -3,12 +3,6 @@ name: Micro Benchmarks on: - pull_request: - type: [opened, reopened, edited] - branches: - # Only for PRs targeting those branches - - master - - v[0-9]+.[0-9]+ schedule: - cron: '30 3 * * *' @@ -43,6 +37,11 @@ jobs: nosetests_node_total: 1 nosetests_node_index: 0 python-version: '3.6' + - name: 'Microbenchmarks' + task: 'micro-benchmarks' + nosetests_node_total: 1 + nosetests_node_index: 0 + python-version: '3.8' services: mongo: image: mongo:4.4