File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -178,12 +178,11 @@ def __getattribute__(self, attr):
178
178
# Only the first thread to get the lock should trigger the load
179
179
# and reset the module's class. The rest can now getattr().
180
180
if object .__getattribute__ (self , '__class__' ) is _LazyModule :
181
- # The first thread comes here multiple times as it descends the
182
- # call stack. The first time, it sets is_loading and triggers
183
- # exec_module(), which will access module.__dict__, module.__name__,
184
- # and/or module.__spec__, reentering this method. These accesses
185
- # need to be allowed to proceed without triggering the load again.
186
- if loader_state ['is_loading' ] and attr .startswith ('__' ) and attr .endswith ('__' ):
181
+ # Reentrant calls from the same thread must be allowed to proceed without
182
+ # triggering the load again.
183
+ # exec_module() and self-referential imports are the primary ways this can
184
+ # happen, but in any case we must return something to avoid deadlock.
185
+ if loader_state ['is_loading' ]:
187
186
return object .__getattribute__ (self , attr )
188
187
loader_state ['is_loading' ] = True
189
188
You can’t perform that action at this time.
0 commit comments