|| at Oct 27, 2010 at 10:41 pm
On Oct 27, 3:21?pm, climb65 wrote:
This class has a destructor which is expected to log something into my log
file if a crash occurs.
Well, the destructor works well but during the crash, python has already
closed the log file and the reference to the Logger has been set to None.
So, I can't log anything!
How is it possible to solve this problem?
Unfortunately, when a process is about to exit (for whatever reason),
things may not shut down in an order you would like. I'd advise
wrapping your main program in an try: except: block. If you have a
main, function, for example:
import logging, sys
logger = logging.getLogger(__name__)
#configure logging, say using basicConfig()
# here is whatever your main program is doing now
retcode = 0
logger.exception('Exception raised during processing')
retcode = 1
if __name__ == '__main__':