#33107: ImportError: partially initialized module '...' has no attribute '...'
---------------------------------+------------------------------------
     Reporter:  Collin Anderson  |                    Owner:  nobody
         Type:  Bug              |                   Status:  new
    Component:  Utilities        |                  Version:  4.0
     Severity:  Release blocker  |               Resolution:
     Keywords:                   |             Triage Stage:  Accepted
    Has patch:  0                |      Needs documentation:  0
  Needs tests:  0                |  Patch needs improvement:  0
Easy pickings:  0                |                    UI/UX:  0
---------------------------------+------------------------------------

Comment (by Keryn Knight):

 Serendipitous find :) For historical reference, it looks like
 `_initializing`  is set via `importlib._bootstrap._load_unlocked`:
 {{{
 # This must be done before putting the module in sys.modules
 # (otherwise an optimization shortcut in import.c becomes
 # wrong).
 spec._initializing = True
 }}}
 Possibly worth noting however is `importlib.util._module_to_load` which
 has equivalent but different (at least in `3.9.5`):
 {{{
 # This must be done before putting the module in sys.modules
 # (otherwise an optimization shortcut in import.c becomes wrong)
 module.__initializing__ = True
 }}}
 If we're going to try and keep the `cached_import`, perhaps we need to
 accommodate both, or at least investigate the `__initializing__`
 variation?

 FWIW, the investigation/patch proposed above does change the performance
 profile (it's `5.64 µs` for me now) but is still world's better than
 repeatedly doing `import_module` (at least until Python `3.11` which might
 improve things via the linked bpo-43392)

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33107#comment:6>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/072.85fe96d7f2323f207847a3d36cf0fcaf%40djangoproject.com.

Reply via email to