On Fri, Feb 7, 2014 at 1:37 PM, Yury Selivanov <yselivanov...@gmail.com>wrote:

>
> On 2/7/2014, 3:52 PM, Guido van Rossum wrote:
>
>> Can't you add a reference to the loop to the tb logger object? The loop
>> should outlive any futures anyway (since the future has a reference to the
>> loop) and it shouldn't be a ref cycle.
>>
>>  Sure.
>
> Another question: "logger.exception" is also used in:
>
> - selector_events.py: in _accept_connection, in case of errors in
> pause_writing/resume_writing and _fatal_error
>
> - proactor_events.py: in case of failed accept, _fatal_error and errors in
> pause/resume writing
>
> - unix_events.py: In pipe transport's _fatal_error,  in case of exception
> in SIGCHLD handler
>
> - windows_events.py: pipe accept failed
>
> All of the above sites are logging exceptions (typically OSErrors). Should
> we use the loop exception API there, or you want to keep using loggers
> directly?
>

I've got a hunch saying that every place where we log an exception we
should use the new handler, but TBH I don't have much of a use case -- I've
been very happy with the default logging and I would probably just be
configuring the logger rather than overriding the exception handler.

I think it's time to ask Glyph for a use case that can't be dealt with by
overriding the logger.


> And one more, aesthetic question: the currently agreed on signature of
> exception handlers is '(loop, context)'. I have a method
> "BaseEventLoop.default_exception_handler(self, context)", but when the
> method is bound, its signature is just '(context)', hence, this bound
> method cannot be passed to 'set_exception_handler'. Should the signature be
> "BaseEventLoop.default_exception_handler(self, loop, context)", or can I
> just make it a staticmethod with '(loop, context)'?
>

But why would you want to pass the default handler to
set_exception_handler()? I had expected that there would be something like
this:

def call_exception_handler(self, exception, context):
    if self._exception_handler is not None:
        try:
            self._exception_handler(self, exception, context)
            return
        except Exception as exc:
            self.default_exception_handler(exc, {'message': 'custom
exception handler failed'})
        self.default_exception_handler(exception, context)

-- 
--Guido van Rossum (python.org/~guido)

Reply via email to