Python has the concept of unraisable exceptions -
exceptions that cannot be raised at the time they occur because they
would break something about the runtime. For example, an exception
raised during an object's __del__
method would break garbage collection.
The use case I came across for this was using asyncio
in debug mode, which warns about unawaited coroutines and unretrieved futures ( https://docs.python.org/3.8/library/asyncio-dev.html#detect-never-awaited-coroutines ). It can be very handy to add a warning filter to turn these RuntimeWarning
s
into exceptions in tests and development. Unfortunately such exceptions are always (or often?) unraisable, so Python prints their stack trace with the default unraisable hook, but carries on as if no error occurred. Failing test runs if unraisable exceptions occur could help highlight such issues.
I'm writing to the mailing list because I'm not sure if failing the test run would always make sense. Does anyone else have experience with unraisable exceptions?
FWIW, pytest has only one stalled discussion: https://github.com/pytest-dev/pytest/issues/5299
--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/df093ae7-5559-42ef-8ca7-3af551a0d14an%40googlegroups.com.
On 30 Oct 2020, at 13:56, Adam Johnson <m...@adamj.eu> wrote:> I'd be making sure we cleaned that up before merge (or, can you filter those... — I guess you can 🤔)In my experience I’d something doesn’t fail, it gets ignored. Few people read the logs of passing test runs and most projects I’ve seen have a pile of noisy warnings making detecting unraisable exceptions even more unreasonable.In the asyncio case, an unraisable exception could indeed represent bad test code, but it could also reveal a bug in the production code which no test assertion would (or even could?) pick up.
--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/5B0EA3FD-CC0D-446E-BACC-3ACDEFEB2682%40gmail.com.
On 30 Oct 2020, at 14:20, Adam Johnson <m...@adamj.eu> wrote:My proposal is to put this into the test runner for Django users
--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/9AD9DB42-5B0D-41CA-995F-2DF4CD92783A%40gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAMyDDM1cDG0vE_EYiLJ_5ih7%3D4Zh4Keofk3oQRx%2BFLFqEhM-ig%40mail.gmail.com.
On 30 Oct 2020, at 17:29, Adam Johnson <m...@adamj.eu> wrote:Focussing only on the asyncio case may be counter productive. They are warnings by default and it requires a warning filter to convert them to exceptions, which are then unraisable.
Would we need to run “gc.collect” after each test to make it deterministic?
--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/351D56E9-B52D-4F3A-9CCE-072C206FEA96%40gmail.com.