File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed
Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -637,6 +637,7 @@ def update(self, flag_builder: FlagBuilderV2) -> TestDataV2:
637637 :param flag_builder: a flag configuration builder
638638 :return: self (the TestDataV2 object)
639639 """
640+ instances_copy = []
640641 try :
641642 self ._lock .lock ()
642643
@@ -650,10 +651,13 @@ def update(self, flag_builder: FlagBuilderV2) -> TestDataV2:
650651
651652 self ._current_flags [flag_builder ._key ] = new_flag
652653 self ._flag_builders [flag_builder ._key ] = flag_builder ._copy ()
654+
655+ # Create a copy of instances while holding the lock to avoid race conditions
656+ instances_copy = list (self ._instances )
653657 finally :
654658 self ._lock .unlock ()
655659
656- for instance in self . _instances :
660+ for instance in instances_copy :
657661 instance .upsert_flag (new_flag )
658662
659663 return self
You can’t perform that action at this time.
0 commit comments