3333"""
3434
3535import time
36- from threading import Lock
3736from typing import Any , List , Optional
3837from uuid import UUID
3938
@@ -64,7 +63,6 @@ def __init__(self, emitter_type_full: bool = True, **kwargs: Any):
6463 self ._generator = SpanGenerator (tracer = self ._tracer )
6564
6665 self ._llm_registry : dict [UUID , LLMInvocation ] = {}
67- self ._lock = Lock ()
6866
6967 def start_llm (
7068 self ,
@@ -79,8 +77,7 @@ def start_llm(
7977 parent_run_id = parent_run_id ,
8078 attributes = attributes ,
8179 )
82- with self ._lock :
83- self ._llm_registry [invocation .run_id ] = invocation
80+ self ._llm_registry [invocation .run_id ] = invocation
8481 self ._generator .start (invocation )
8582
8683 def stop_llm (
@@ -89,8 +86,7 @@ def stop_llm(
8986 chat_generations : List [OutputMessage ],
9087 ** attributes : Any ,
9188 ) -> LLMInvocation :
92- with self ._lock :
93- invocation = self ._llm_registry .pop (run_id )
89+ invocation = self ._llm_registry .pop (run_id )
9490 invocation .end_time = time .time ()
9591 invocation .chat_generations = chat_generations
9692 invocation .attributes .update (attributes )
@@ -100,8 +96,7 @@ def stop_llm(
10096 def fail_llm (
10197 self , run_id : UUID , error : Error , ** attributes : Any
10298 ) -> LLMInvocation :
103- with self ._lock :
104- invocation = self ._llm_registry .pop (run_id )
99+ invocation = self ._llm_registry .pop (run_id )
105100 invocation .end_time = time .time ()
106101 invocation .attributes .update (** attributes )
107102 self ._generator .error (error , invocation )
0 commit comments