Skip to content

Commit 21ab3bb

Browse files
committed
Fix settings.context finally block: main_thread_config
1 parent 5c2ee6a commit 21ab3bb

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

dsp/utils/settings.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class Settings:
4949
def __new__(cls):
5050
if cls._instance is None:
5151
cls._instance = super().__new__(cls)
52-
cls._instance.lock = threading.Lock() # maintained here for assertions
52+
# No need for a lock since we're only updating main_thread_config in the main thread
5353
return cls._instance
5454

5555
def __getattr__(self, name):
@@ -113,6 +113,10 @@ def context(self, **kwargs):
113113
finally:
114114
dspy_ctx_overrides.reset(token)
115115

116+
if threading.current_thread() is threading.main_thread():
117+
global main_thread_config
118+
main_thread_config = dspy_ctx_overrides.get()
119+
116120
def __repr__(self):
117121
overrides = dspy_ctx_overrides.get()
118122
combined_config = {**main_thread_config, **overrides}

0 commit comments

Comments
 (0)