Re: My sys.excepthook dies painfully

2014-07-24 Thread Chris Angelico
On Thu, Jul 24, 2014 at 8:12 PM, Steven D'Aprano wrote: >> Would it be possible to snapshot all critical globals with a closure, to >> force them to be held? Something like: > > Probably. Or even as default argument parameters. But I'd like to know if > that's actually fixing it or just perturbing

Re: My sys.excepthook dies painfully

2014-07-24 Thread Steven D'Aprano
On Thu, 24 Jul 2014 11:50:47 +1000, Chris Angelico wrote: > On Thu, Jul 24, 2014 at 11:30 AM, Steven D'Aprano > wrote: >> However, I think I have a glimmer of an idea for how the global >> variable might be set to None. When the Python interpreter shuts down, >> it sets global variables to None i

Re: My sys.excepthook dies painfully

2014-07-23 Thread Jason Swails
On Wed, Jul 23, 2014 at 6:30 PM, Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info> wrote: > On Wed, 23 Jul 2014 13:02:51 -0700, Jason Swails wrote: > > > I'm not sure how the "mylogger" variable is getting set to None in your > > my_error_handler callback, but I don't see how that can possib

Re: My sys.excepthook dies painfully

2014-07-23 Thread Steven D'Aprano
On Thu, 24 Jul 2014 01:30:41 +, Steven D'Aprano wrote: > I wonder whether I ought to use atexit to register the function, rather > than mess with sys.excepthook directly? Ignore this. I was smoking crack. atexit has nothing to do with sys.excepthook and won't solve my problem. -- Steven -

Re: My sys.excepthook dies painfully

2014-07-23 Thread dieter
Steven D'Aprano writes: > I have some code which sets up a logger instance, then installs it as > sys.excepthook to capture any uncaught exceptions: > > > > import logging > import logging.handlers > import sys > > FACILITY = logging.handlers.SysLogHandler.LOG_LOCAL6 > mylogger = logging.getLogge

Re: My sys.excepthook dies painfully

2014-07-23 Thread Chris Angelico
On Thu, Jul 24, 2014 at 11:30 AM, Steven D'Aprano wrote: > However, I think I have a glimmer of an idea for how the global variable > might be set to None. When the Python interpreter shuts down, it sets > global variables to None in some arbitrary order. If the excepthook > function isn't called

Re: My sys.excepthook dies painfully

2014-07-23 Thread Steven D'Aprano
On Wed, 23 Jul 2014 13:02:51 -0700, Jason Swails wrote: > I'm not sure how the "mylogger" variable is getting set to None in your > my_error_handler callback, but I don't see how that can possibly be > happening with the provided code... Dammit, it's a Heisenbug... now it's gone away for me too.

Re: My sys.excepthook dies painfully

2014-07-23 Thread Jason Swails
On Jul 23, 2014, at 1:02 AM, Chris Angelico wrote: > On Wed, Jul 23, 2014 at 5:46 PM, Steven D'Aprano wrote: >> On Wed, 23 Jul 2014 07:14:27 +, Steven D'Aprano wrote: >> >>> I have some code which sets up a logger instance, then installs it as >>> sys.excepthook to capture any uncaught exc

Re: My sys.excepthook dies painfully

2014-07-23 Thread Chris Angelico
On Wed, Jul 23, 2014 at 5:46 PM, Steven D'Aprano wrote: > On Wed, 23 Jul 2014 07:14:27 +, Steven D'Aprano wrote: > >> I have some code which sets up a logger instance, then installs it as >> sys.excepthook to capture any uncaught exceptions: > > Oh! I should have said, I'm running Python 2.6.

Re: My sys.excepthook dies painfully

2014-07-23 Thread Steven D'Aprano
On Wed, 23 Jul 2014 07:14:27 +, Steven D'Aprano wrote: > I have some code which sets up a logger instance, then installs it as > sys.excepthook to capture any uncaught exceptions: Oh! I should have said, I'm running Python 2.6. -- Steven -- https://mail.python.org/mailman/listinfo/python

Re: My sys.excepthook dies painfully

2014-07-23 Thread Chris Angelico
On Wed, Jul 23, 2014 at 5:14 PM, Steven D'Aprano wrote: > Error in sys.excepthook: > Traceback (most recent call last): > File "/home/steve/mylogging.py", line 28, in my_error_handler > mylogger.exception(msg) > AttributeError: 'NoneType' object has no attribute 'exception' > > Original exce

My sys.excepthook dies painfully

2014-07-23 Thread Steven D'Aprano
I have some code which sets up a logger instance, then installs it as sys.excepthook to capture any uncaught exceptions: import logging import logging.handlers import sys FACILITY = logging.handlers.SysLogHandler.LOG_LOCAL6 mylogger = logging.getLogger('spam') handler = logging.handlers.SysLog