Skip to content

Commit 5652bd3

Browse files
committed
fix lock issue
1 parent a9e8ee2 commit 5652bd3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

ldclient/integrations/test_datav2.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)