Qix- / better-exceptions

Pretty and useful exceptions in Python, automatically.
MIT License
4.6k stars 204 forks source link

Write exception to stderr lazily #66

Closed Delgan closed 5 years ago

Delgan commented 5 years ago

In #37, user noticed that its program was hanging forever because of exception formatting. Some weird asynchronous / recursive calls prevented better_exceptions to retrieve repr(value).

I am not sure there is much we can do to fix it. However, I think we can ease for the user the process of identifying the issue by displaying better_exceptions tracebacks progressively.

That is, if user remarks that its program is hanging forever, he will start investigating it, but I think it will take time before considering that the issue may come from the exception formatting. However, by printing the exception line by line on our side, the user will see Traceback (most recent call last): and then nothing. So, he will immediately jump to the conclusion that maybe something is going wrong in better_exceptions hook.

@Qix- Do you think it worth merging it?

Qix- commented 5 years ago

I've given this some thought and I think having blocking operations in __str__ or, even worse, __repr__ is an anti-pattern of sorts. I equate it to doing I/O inside draw calls on a rendering thread.

That's not really a use-case I think BE should support, personally.

Delgan commented 5 years ago

Yeah, I think you are right. Thanks!