File tree Expand file tree Collapse file tree
test-django-admin-query-perf Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Django
2+ __pycache__ /
3+ * .pyc
4+ * .pyo
5+ * .pyd
6+ .Python
7+ db.sqlite3
8+
9+ # Environment
10+ .env
11+ .venv
12+
13+ # IDE
14+ .vscode /
15+ .idea /
16+
17+ # Mac
18+ .DS_Store
19+
20+ latest.pstats
Original file line number Diff line number Diff line change 2626# SECURITY WARNING: don't run with debug turned on in production!
2727DEBUG = True
2828
29- ALLOWED_HOSTS = []
29+ ALLOWED_HOSTS = ['localhost' , '127.0.0.1' , 'testserver' ]
3030
3131
3232# Application definition
143143 environment = os .environ .get ("SENTRY_ENV" , "local" ),
144144 traces_sample_rate = 1.0 ,
145145 profiles_sample_rate = 1.0 ,
146+ debug = True ,
146147)
Original file line number Diff line number Diff line change 1+ # The gunicorn "configuration" file
2+
3+ import cProfile
4+
5+ profile = cProfile .Profile ()
6+
7+ def pre_request (worker , req ):
8+ print ("enabling profile for the request" )
9+ profile .enable ()
10+
11+ def post_request (worker , req , * args ):
12+ profile .disable ()
13+ print ("request done, profile disabled now" )
14+
15+ def worker_exit (server , worker ):
16+ # Write pstats to file that can then by viewed with snakeviz
17+ # profile.dump_stats("latest.pstats")
18+
19+ # Print stats to console
20+ profile .print_stats ()
21+
22+ print ("process exiting, dumping stats to file" )
Original file line number Diff line number Diff line change 11[project ]
22name = " test"
33version = " 0"
4- # requires-python = "==3.11.11"
5- requires-python = " ==3.13.5"
4+ requires-python = " ==3.11.11"
5+ # requires-python = "==3.13.5"
66
77dependencies = [
88 " ipdb>=0.13.13" ,
99 " sentry-sdk[django]" ,
1010 " daphne>=4.2.1" ,
11- # "django~=4.2.0 ",
12- " django>=5.2.5 " ,
11+ # "django~=4.2.24 ",
12+ " django===5.0 " ,
1313 " psycopg>=3.1.0" ,
1414 " gunicorn>=23.0.0" ,
1515 " whitenoise>=6.5.0" ,
16+ " uvicorn>=0.35.0" ,
17+ " uwsgi>=2.0.30" ,
18+ " snakeviz>=2.2.2" ,
1619]
1720
1821# comment this out to install from pypi
Original file line number Diff line number Diff line change @@ -8,6 +8,16 @@ if ! command -v uv &> /dev/null; then
88 curl -LsSf https://astral.sh/uv/install.sh | sh
99fi
1010
11+ uv sync
12+
1113# Run Django with Gunicorn
1214export SENTRY_ENV=gunicorn
13- uv run gunicorn --bind 0.0.0.0:8000 django_admin_sentry_perf.wsgi:application
15+ uv run gunicorn --bind 0.0.0.0:8000 --timeout 50000 django_admin_sentry_perf.wsgi:application
16+
17+ # Run Django with Gunicorn with async worker
18+ # export SENTRY_ENV=gunicorn
19+ # uv run gunicorn -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000 django_admin_sentry_perf.asgi:application
20+
21+ # Run Django with uWSGI
22+ # export SENTRY_ENV=uwsgi
23+ # uv run uwsgi --http :8000 --module django_admin_sentry_perf.wsgi
You can’t perform that action at this time.
0 commit comments