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 thread as to not block the main program?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
No, you should spawn a separate process, as far as I know.
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.