@@ -779,9 +779,10 @@ class DataEntry(NamedTuple):
779
779
780
780
@_logger .call (condition = lambda self : not self ._initialized )
781
781
async def ensure_initialized (self ) -> bool :
782
- async with self . _initialize_lock :
783
- imports_changed = False
782
+ run_initialize = False
783
+ imports_changed = False
784
784
785
+ async with self ._initialize_lock :
785
786
if not self ._initialized :
786
787
787
788
if self ._in_initialize :
@@ -804,14 +805,7 @@ async def ensure_initialized(self) -> bool:
804
805
elif old_imports != imports :
805
806
imports_changed = True
806
807
807
- new_imports = []
808
- for e in old_imports :
809
- if e in imports :
810
- new_imports .append (e )
811
- for e in imports :
812
- if e not in new_imports :
813
- new_imports .append (e )
814
- self .document .set_data (Namespace , new_imports )
808
+ self .document .set_data (Namespace , imports )
815
809
self .document .set_data (Namespace .DataEntry , None )
816
810
else :
817
811
data_entry = self .document .get_data (Namespace .DataEntry )
@@ -849,6 +843,7 @@ async def ensure_initialized(self) -> bool:
849
843
await self ._reset_global_variables ()
850
844
851
845
self ._initialized = True
846
+ run_initialize = True
852
847
853
848
except BaseException as e :
854
849
if not isinstance (e , asyncio .CancelledError ):
@@ -863,7 +858,7 @@ async def ensure_initialized(self) -> bool:
863
858
finally :
864
859
self ._in_initialize = False
865
860
866
- if self . _initialized :
861
+ if run_initialize :
867
862
await self .has_initialized (self )
868
863
869
864
if imports_changed :
0 commit comments