Should I acquire lock for logging.Handler.flush()?

Fayaz Yusuf Khan fayaz.yusuf.khan at gmail.com
Wed Feb 22 05:44:44 CET 2012


On Tuesday 21 Feb 2012 12:52:14 PM Vinay Sajip wrote:
> If you are using SMTPHandler, calling flush() won't do anything.
> You'll probably need to subclass the handler to implement rate
> limiting.
Oh, no! I'm writing my own handler.
https://github.com/fayazkhan/ses_handler/blob/master/ses_handler.py
Now I understand from here 
http://docs.python.org/library/logging.html#handler-objects
that emit() calls are wrapped acquire() and release() in the handle() method.

Anyway, I read the source and found many interesting things that ought to be 
mentioned in the docs.
Such as flush() should be called from close() whenever it's implemented. 
(FileHandler.close() is doing it)
And how come close()/flush() isn't being called from inside a lock?
(Handler.close() calls the module level _acquireLock() and _releaseLock()s but 
nothing about the instance level acquire() or release())
Or is it being locked from somewhere else?
-- 
Fayaz Yusuf Khan
Cloud developer and architect
Dexetra SS, Bangalore, India
fayaz.yusuf.khan_AT_gmail_DOT_com
fayaz_AT_dexetra_DOT_com
+91-9746-830-823
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.python.org/pipermail/python-list/attachments/20120222/723e4ec0/attachment.sig>


More information about the Python-list mailing list