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

Django configuration compatibility #24

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

quinnmil
Copy link
Collaborator

@quinnmil quinnmil commented Jan 23, 2025

Changes

  • Fixes an issue where configuration from the Django settings.py was not loaded by the time the handler was initialized, which would result in failed startup.
  • Now, the handler waits to initialize until the first time emit is called.
  • Since the initialization process can itself emit log messages, this can cause infinite recursion, so to avoid this, we add a flag to check for an initialization in-progress to avoid the multiple init calls which are made when django sets up logging. We use a thread thread lock to further guard against recursion/race conditions.

Notes

  • This is hardly the most elegant solution. The proper way to do a django logger is probably be the package to be added an an app and/or middleware. Still, this does work, and is sufficient for the time being.

@quinnmil quinnmil linked an issue Jan 23, 2025 that may be closed by this pull request
@quinnmil quinnmil force-pushed the 23-django-configuration-compatibility branch from ec864e2 to b2e0947 Compare January 23, 2025 22:46
@quinnmil quinnmil changed the title 23 django configuration compatibility Django configuration compatibility Jan 24, 2025
@quinnmil quinnmil force-pushed the 23-django-configuration-compatibility branch from b2e0947 to e11a407 Compare January 24, 2025 18:33
@quinnmil quinnmil marked this pull request as ready for review January 24, 2025 18:59
@quinnmil quinnmil force-pushed the 23-django-configuration-compatibility branch from e11a407 to bd7a7df Compare January 24, 2025 21:28
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.

Handler not configured when configuration set in django settings.py
1 participant