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

Vinay Sajip vinay_sajip at yahoo.co.uk
Tue Feb 21 21:52:14 CET 2012


On Feb 21, 7:23 am, Fayaz Yusuf Khan <fayaz.yusuf.k... at gmail.com>
wrote:
> I'm writing a custom logging Handler that sends emails through AWS Simple
> Email Service using the boto library.
> As there's a quota cap on how many (200) emails I can send within 24hrs, I
> think I need to buffer my log messages from the emit() calls (Or is that a bad
> idea?).
> And I was reading the Handler documentation and was confused if I should call
> the acquire() and release() methods from within a flush() call.
> --
> 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
>
>  signature.asc
> < 1KViewDownload

If you are using SMTPHandler, calling flush() won't do anything.
You'll probably need to subclass the handler to implement rate
limiting.

In the stdlib, only StreamHandler and its subclasses actually
implement flush(), which flushes I/O buffers to disk.

Regards,

Vinay Sajip



More information about the Python-list mailing list