Skip to content

Commit 3fa1f40

Browse files
committed
get in losers, we're hunting memory leaks
1 parent 7e82771 commit 3fa1f40

File tree

8 files changed

+58
-11
lines changed

8 files changed

+58
-11
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
/.state
55
/staticfiles
66
.coverage
7+
/memray-*

Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
FROM python:3.13-alpine
1+
FROM python:3.13
22

3-
RUN apk add --no-cache bash
3+
RUN apt install bash
44

55
ENV PYTHONUNBUFFERED=1
66
ENV PYTHONDONTWRITEBYTECODE=1
77
RUN mkdir /code
88
WORKDIR /code
99
COPY requirements.txt /tmp/requirements.txt
10+
1011
RUN --mount=type=cache,target=/root/.cache/pip \
1112
pip install -r /tmp/requirements.txt
1213

Procfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
release: python manage.py migrate
2-
web: gunicorn -c gunicorn.conf.py clabot.asgi:application --log-file -
2+
web: memray run --native --follow-fork -f -m gunicorn -c gunicorn.conf.py clabot.asgi:application --log-file -
33
worker: python manage.py db_worker

compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ services:
2424

2525
web:
2626
image: clabot:docker-compose
27-
command: python manage.py runserver 0.0.0.0:8000
27+
command: memray run --native --follow-fork -f -m gunicorn -c gunicorn.conf.dev.py clabot.asgi:application --log-file -
2828
environment: *base_environment
2929
ports:
3030
- "8000:8000"

gunicorn.conf.dev.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
bind = '0.0.0.0:8000'
2+
worker_class = "clabot.workers.UvicornWorker"
3+
workers = 1
4+
5+
backlog = 2048
6+
preload_app = True
7+
#max_requests = 2048
8+
#max_requests_jitter = 128
9+
10+
timeout = 60
11+
keepalive = 2
12+
13+
errorlog = "-"
14+
loglevel = "info"
15+
accesslog = "-"
16+
access_log_format = '%(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s" %(M)'

gunicorn.conf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
bind = "unix:/var/run/cabotage/cabotage.sock"
22
worker_class = "clabot.workers.UvicornWorker"
3-
workers = 2
3+
workers = 1
44

55
backlog = 2048
66
preload_app = True
7-
max_requests = 2048
8-
max_requests_jitter = 128
7+
#max_requests = 2048
8+
#max_requests_jitter = 128
99

1010
timeout = 60
1111
keepalive = 2

requirements.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,7 @@ sentry_sdk
2323
servestatic
2424
stamina
2525
uvicorn
26+
27+
# Debug
28+
memray
29+
pystack

requirements.txt

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,29 @@ iniconfig==2.1.0
108108
# via pytest
109109
isort==6.0.1
110110
# via -r requirements.in
111+
jinja2==3.1.6
112+
# via memray
113+
linkify-it-py==2.0.3
114+
# via markdown-it-py
111115
markdown==3.7
112116
# via django-markdownx
113-
markdown-it-py==3.0.0
114-
# via rich
117+
markdown-it-py[linkify,plugins]==3.0.0
118+
# via
119+
# mdit-py-plugins
120+
# rich
121+
# textual
122+
markupsafe==3.0.2
123+
# via jinja2
115124
marshmallow==3.26.1
116125
# via environs
117126
mccabe==0.7.0
118127
# via flake8
128+
mdit-py-plugins==0.4.2
129+
# via markdown-it-py
119130
mdurl==0.1.2
120131
# via markdown-it-py
132+
memray==1.17.1
133+
# via -r requirements.in
121134
mypy-extensions==1.0.0
122135
# via black
123136
oauthlib==3.2.2
@@ -136,7 +149,9 @@ pillow==11.1.0
136149
pip-tools==7.4.1
137150
# via -r requirements.in
138151
platformdirs==4.3.7
139-
# via black
152+
# via
153+
# black
154+
# textual
140155
pluggy==1.5.0
141156
# via pytest
142157
psycopg2-binary==2.9.10
@@ -165,6 +180,8 @@ pyproject-hooks==1.2.0
165180
# via
166181
# build
167182
# pip-tools
183+
pystack==1.4.1
184+
# via -r requirements.in
168185
pytest==8.3.5
169186
# via
170187
# -r requirements.in
@@ -179,7 +196,10 @@ python-dotenv==1.1.0
179196
requests==2.32.3
180197
# via -r requirements.in
181198
rich==13.9.4
182-
# via django-typer
199+
# via
200+
# django-typer
201+
# memray
202+
# textual
183203
sentry-sdk==2.25.1
184204
# via -r requirements.in
185205
servestatic==3.0.1
@@ -196,6 +216,8 @@ stamina==25.1.0
196216
# via -r requirements.in
197217
tenacity==9.1.2
198218
# via stamina
219+
textual==3.1.1
220+
# via memray
199221
twisted[tls]==24.11.0
200222
# via daphne
201223
txaio==23.1.1
@@ -207,8 +229,11 @@ typing-extensions==4.13.0
207229
# dj-database-url
208230
# django-stubs-ext
209231
# django-tasks
232+
# textual
210233
# twisted
211234
# typer-slim
235+
uc-micro-py==1.0.3
236+
# via linkify-it-py
212237
uritemplate==4.1.1
213238
# via gidgethub
214239
urllib3==2.3.0

0 commit comments

Comments
 (0)