Skip to content

Conversation

@quinnmil
Copy link
Contributor

@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
@quinnmil quinnmil force-pushed the 23-django-configuration-compatibility branch from bd7a7df to 2c1fc8b Compare January 24, 2025 21:30
@quinnmil quinnmil merged commit 9999366 into main Jan 28, 2025
7 checks passed
@quinnmil quinnmil deleted the 23-django-configuration-compatibility branch January 28, 2025 17:49
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

3 participants