Improve sandboxing of broken extensions.
Review Request #10959 — Created March 17, 2020 and submitted — Latest diff uploaded
When loading extensions, we attempt to catch some common initialization
errors and present them in the extension manager interface, so that
developers or end users have a sense of what's going on. This has worked
fine for extensions involving the initialization of the extenison
itself, but didn't cover issues like syntax errors, issues with the
administration URLs, media installation, or others.This change attempts improve upon this by capturing more failures that
can occur and insulating the rest of the product from those failures,
ensuring we don't, for instance, have stale extension state sitting around.Along with this, it tries bullet-proof signal management for extensions
so a bad handler can't further break things during the enabling or
disabling of an extension.
Hit this on release-2.0.x with some older extensions on Django 1.11,
and with old Python 2 code on Python 3. Verified that various issues
(such as half-loaded extensions, extension state ref count inconsistencies,
and issues re-enabling extensions) weren't hit.Unit tests pass. Note that there are no new unit tests in this change, and
that's partly because the extension test suite was completely redone between
Djblets 1.0 and 2.0. There's some work in the queue on improving tests for
this for 2.0.