Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch StaticFilesPanel to use ContextVar. #1801

Merged

Conversation

tim-schilling
Copy link
Member

The StaticFilesPanel thread collector was not closing connections to the database. This approach allows those connections to be closed while still collecting context across threads.

The test case is to hit an admin login screen with

ab -n 200 http://localhost:8000/admin/login/

As far as I can tell, all the static files are collected properly and connections don't stay open.

Fixes #1799

Checklist:

  • I have added the relevant tests for this change.
  • I have added an item to the Pending section of docs/changes.rst.

The StaticFilesPanel thread collector was not closing connections
to the database. This approach allows those connections to be closed
while still collecting context across threads.

The test case is to hit an admin login screen with

    ab -n 200 http://localhost:8000/admin/login/

As far as I can tell, all the static files are collected properly and
connections don't stay open.
Copy link
Member

@matthiask matthiask left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't try it out, I only read the code. Using contextvars is a great idea.

@matthiask matthiask merged commit 47d4eed into django-commons:main Jul 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

django-debug-toolbar is crashing postgresql by not closing connections
2 participants