Hi all,

Although not explicitly mentioned anywhere, I've come to the conclusion 
Django blocks while writing logs with some handlers (it uses Python 
logging, 
https://docs.python.org/3/howto/logging-cookbook.html#dealing-with-handlers-that-block).

I can't find anything that explicitly states Django handles this already 
(in the code or documentation) and I believe it to be a problem in the 
platform I am working on. Justification for this belief is loose at best, 
but it's the best lead I have (specifically, the SysLogHandler seems like 
it might be blocking on sending to a UDP port, which seems crazy but 
apparently is possible)

I'm setting trying to see if I can solve this, but there seems to be very 
little details on this subject, and that alone worries me. So I have a 
couple questions for anyone willing to entertain me:


   1. Is it silly to be worried about this? My gut says yes, simply because 
   nobody else is. At the same time I see no real downside to logging 
   asynchronously (is that true?). There are potential upsides. It might not 
   solve the real problem (what is causing buffers to back up in the first 
   place? likely crazy I/O usage) but it might speed up handling of requests 
   during heavy I/O.
   2. Have you done anything similar to this? How did you approach it?
   3. The QueueHandler suggested in the Python cookbook doesn't seem to be 
   easy to stuff into Django. We have Django running behind Gunicorn, so my 
   thought was to have Gunicorn spin up a QueueListener process, and then have 
   Gunicorn pass the queue to each worker similar to this 
   cookbook: 
https://docs.python.org/3/howto/logging-cookbook.html#logging-to-a-single-file-from-multiple-processes
 
   -- I'm interested on any thoughts on this approach. Especially if there is 
   a better way.

Cheers,
Dan

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ce269c78-bd6b-4e06-b9de-2da6ccc79cd8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to