Do Logging Handlers Use Separate Threads?
Python's logging handlers are great. Some of them, such as the SMTPHandler may take a long while to execute (contacting an SMTP server and all). Are they executed on a separate thr
Solution 1:
SMTPHandler uses smtplib and when sending an email with this library, your process is blocked until it have been correctly sent, no thread created.
If you do not want to block your process when sending an email, you'll have to implement your own SMTPHandler and override the emit(self, record)
method.
The less blocking handler is the SysLogHandler, because it is in general a local communication, and in UDP so the system doesn't wait for any acknowledgement from the destination.
Solution 2:
No, you should spawn a separate process, as far as I know.
Post a Comment for "Do Logging Handlers Use Separate Threads?"