Skip to content

Commit

Permalink
loose restrict of greenlet (#3) (#326)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaychoww authored Nov 4, 2023
1 parent 1a36022 commit 9b1acaa
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 124 deletions.
235 changes: 127 additions & 108 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ grpcio = '*'
grpcio-tools = '*'
packaging = '*'
wrapt = '*'
psutil = '*'
psutil = '<=5.9.5'
requests = { version = ">=2.26.0", optional = true }
kafka-python = { version = "*", optional = true }
uvloop = { version = "^0.17.0", optional = true }
Expand Down Expand Up @@ -129,7 +129,7 @@ celery = "5.1.2"
django = "3.2.8"
elasticsearch = "7.15.1"
flask = "2.0.2"
gevent = "22.8.0"
gevent = "22.10.2"
hug = "2.6.1"
pika = "1.2.0"
psycopg = {extras = ["binary"], version = "^3.1.7"}
Expand Down
15 changes: 6 additions & 9 deletions skywalking/profile/profile_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import time
import traceback

from packaging import version
from threading import Thread, Event, current_thread
from typing import Optional

Expand All @@ -43,15 +42,12 @@
from gevent.exceptions import BlockingSwitchOutError

if monkey.is_module_patched('threading'):
if version.parse(greenlet.__version__) <= version.parse('1.1.3.post0'):
# todo: greenlet will raise a segment fault with signal 11 when it upgrade to 2.0.0
# this issue may be caused by gevent's compatibility with greenlet
# we should do some tests when gevent release a new version to verify if this issue would be fixed
THREAD_MODEL = 'greenlet'
else:
logger.warn('greenlet profiler can not work with version >= 2.0.0')
THREAD_MODEL = 'greenlet'
logger.debug('Using greenlet model')
else:
logger.debug('Gevent monkey exists but does not patch threading, using threading model')
except ImportError:
pass
logger.debug("Gevent does\'t exist, using threading model")


class ProfileTaskExecutionContext:
Expand Down Expand Up @@ -326,6 +322,7 @@ def build_snapshot(self) -> Optional[TracingThreadSnapshot]:


def start_profiling(self, context: ProfileTaskExecutionContext):
logger.debug('GreenletProfiler::start_profiling')
self._task_execution_context = context
try:
curr = self._profiling_thread
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/base/Dockerfile.e2e
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ RUN cd /skywalking-python && apt-get update && apt-get install -y make && make i
RUN apt-get update \
&& apt-get install -y --no-install-recommends gcc build-essential\
&& rm -rf /var/lib/apt/lists/* \
&& pip install uwsgi fastapi uvicorn aiohttp flask gunicorn\
&& pip install uwsgi fastapi uvicorn aiohttp flask "Werkzeug<3" gunicorn \
&& apt-get purge -y --auto-remove gcc build-essential

# Entrypoint with agent attached
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/case/profiling/greenlet/start_gevent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
#

set -ex
pip install gunicorn gevent "greenlet<2.0.0"
gunicorn -k gevent -b :9090 --chdir /services entrypoint:app
pip install gunicorn gevent "greenlet>=3"
gunicorn -k gevent -b :9090 --chdir /services entrypoint:app
4 changes: 2 additions & 2 deletions tests/plugin/web/sw_flask/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ services:
- 9091:9091
volumes:
- .:/app
command: ['bash', '-c', 'pip install flask itsdangerous==2.0.1 && pip install -r /app/requirements.txt && sw-python run python3 /app/services/provider.py']
command: ['bash', '-c', 'pip install flask itsdangerous==2.0.1 "Werkzeug<3" && pip install -r /app/requirements.txt && sw-python run python3 /app/services/provider.py']
depends_on:
collector:
condition: service_healthy
Expand All @@ -52,7 +52,7 @@ services:
- 9090:9090
volumes:
- .:/app
command: ['bash', '-c', 'pip install flask itsdangerous==2.0.1 && pip install -r /app/requirements.txt && sw-python run python3 /app/services/consumer.py']
command: ['bash', '-c', 'pip install flask itsdangerous==2.0.1 "Werkzeug<3" && pip install -r /app/requirements.txt && sw-python run python3 /app/services/consumer.py']
depends_on:
collector:
condition: service_healthy
Expand Down

0 comments on commit 9b1acaa

Please sign in to comment.