Issue with "log object has expired" Error in Apache/Mod_WSGI with Django 5.0.9 and Python 3.13

I am encountering a RuntimeError: log object has expired error when running my Django 5.0.9 application using Apache and mod_wsgi. The error appears in my error.log whenever a request is made.

It seems to be related to how the WSGI error log stream is being handled or closed prematurely, but I’m unsure of the exact root cause.
Context:

  • Django Version: 5.0.9
  • Python Version: 3.13.0
  • mod_wsgi Version: 5.0.1 (installed via pip)
  • Apache Version: 2.4 (Windows)
  • Platform: Windows Server (local machine setup)

Could this error be related to how mod_wsgi is handling the WSGI error stream or an issue with threading in Apache? Has anyone encountered this with Python 3.13, mod_wsgi, or Django 5.0.9?

I would appreciate any insights or suggestions on how to resolve this issue, as it only occurs in the Apache + mod_wsgi environment and not in Django’s development server.