DSPy: The framework for programming—not prompting—language models
Python
modified threading handling in config for multithreaded flask
Arnav Singhvi2f92d473d7ae
diff --git a/dsp/utils/settings.py b/dsp/utils/settings.pyindex 3d27eb384..290f364b5 100644--- a/dsp/utils/settings.py+++ b/dsp/utils/settings.py@@ -39,7 +39,10 @@ class Settings(object):@propertydef config(self):- return self.stack_by_thread[threading.get_ident()][-1]+ thread_id = threading.get_ident()+ if thread_id not in self.stack_by_thread:+ self.stack_by_thread[thread_id] = [self.main_stack[0].copy()]+ return self.stack_by_thread[thread_id][-1]def __getattr__(self, name):if hasattr(self.config, name):@@ -51,10 +54,15 @@ class Settings(object):super().__getattr__(name)def __append(self, config):- self.stack_by_thread[threading.get_ident()].append(config)+ thread_id = threading.get_ident()+ if thread_id not in self.stack_by_thread:+ self.stack_by_thread[thread_id] = [self.main_stack[0].copy()]+ self.stack_by_thread[thread_id].append(config)def __pop(self):- self.stack_by_thread[threading.get_ident()].pop()+ thread_id = threading.get_ident()+ if thread_id in self.stack_by_thread:+ self.stack_by_thread[thread_id].pop()def configure(self, inherit_config: bool = True, **kwargs):"""Set configuration settings.