You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Django Server Hangs During Startup/Shutdown Due to Blocking LogtailHandler.flush() #35
Django server hangs indefinitely during startup/shutdown when LogtailHandler is enabled. When commenting out the logtail configuration, the server works fine. This issue occurs consistently but not always - depends on timing and network conditions.
Root Cause
The LogtailHandler.flush() method blocks indefinitely in an infinite loop without timeout:
Add LogtailHandler to Django logging configuration
Start Django server: python manage.py runserver
Stop server with Ctrl+C
Result: Server hangs and must be force-killed
Workaround: Commenting out logtail handler makes Django work normally.
Error When Force-Interrupted
Traceback (most recent call last):
File "/usr/lib/python3.11/logging/__init__.py", line 2185, in shutdown
h.flush()
File "logtail/flusher.py", line 83, in flush
time.sleep(self.check_interval)
KeyboardInterrupt:
Environment
Python 3.11, Django 3.2.8+, logtail 0.3.3
Proposed Fix
Add a flush_timeout parameter (default 5 seconds) to prevent infinite waiting:
defflush(self):
self._flushing=Truestart_time=time.time()
whilenotself._cleanornotself.pipe.empty():
iftime.time() -start_time>self.flush_timeout:
break# Exit after timeouttime.sleep(self.check_interval)
self._flushing=False
Impact
Prevents graceful Django shutdown
Affects development workflow and deployment scripts
Thank you for such a detailed report 🙌 We have recently added a configurable timeout in v0.3.4, which should make sure that server doesn't hang indefinitely.
Would that solve this issue as well? Would you be so kind as to upgrade from v0.3.3 🙏
The default timeout might still be a little too high for the development workflow though... What do you think?
Thank you for such a detailed report 🙌 We have recently added a configurable timeout in v0.3.4, which should make sure that server doesn't hang indefinitely.
Would that solve this issue as well? Would you be so kind as to upgrade from v0.3.3 🙏
The default timeout might still be a little too high for the development workflow though... What do you think?
Wow @PetrHeinz,
thanks for your swift reply! 🙇 That’s highly appreciated.
The Kudos go out to @vikram-typeset for the detailed report - I just sent a ping ;-)
We’re currently using Mezmo (previously logdna) and face this issue:
Unfortunately there has been no reaction by Mezmo. And yes, we’re currently evaluating betterstack :-)
As soon as we try out betterstack with Django, we’ll give you an update whether v0.3.3 does the job.
Activity
dbartenstein commentedon Sep 29, 2025
@vikram-typeset is your issue maybe solved with version 0.3.4? https://github.com/logtail/logtail-python/releases/tag/v0.3.4
dbartenstein commentedon Oct 13, 2025
@PetrHeinz what’s your take on this?
PetrHeinz commentedon Oct 13, 2025
Hi @dbartenstein,
Thank you for such a detailed report 🙌 We have recently added a configurable timeout in v0.3.4, which should make sure that server doesn't hang indefinitely.
Would that solve this issue as well? Would you be so kind as to upgrade from v0.3.3 🙏
The default timeout might still be a little too high for the development workflow though... What do you think?
dbartenstein commentedon Oct 13, 2025
Wow @PetrHeinz,
thanks for your swift reply! 🙇 That’s highly appreciated.
The Kudos go out to @vikram-typeset for the detailed report - I just sent a ping ;-)
We’re currently using Mezmo (previously logdna) and face this issue:
Unfortunately there has been no reaction by Mezmo. And yes, we’re currently evaluating betterstack :-)
As soon as we try out betterstack with Django, we’ll give you an update whether v0.3.3 does the job.