Skip to content

Commit c19ad6e

Browse files
authored
Move _should_stop initialization to __init__ (elevenlabs#426)
Avoid using mutable default values for _should_stop by initializing it in the __init__ method to ensure instance-level independence.
1 parent 0a5a4e0 commit c19ad6e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/elevenlabs/conversational_ai/conversation.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class Conversation:
7474
callback_latency_measurement: Optional[Callable[[int], None]]
7575

7676
_thread: Optional[threading.Thread] = None
77-
_should_stop: threading.Event = threading.Event()
77+
_should_stop: threading.Event
7878
_conversation_id: Optional[str] = None
7979
_last_interrupt_id: int = 0
8080

@@ -119,6 +119,7 @@ def __init__(
119119
self.callback_agent_response_correction = callback_agent_response_correction
120120
self.callback_user_transcript = callback_user_transcript
121121
self.callback_latency_measurement = callback_latency_measurement
122+
self._should_stop = threading.Event()
122123

123124
def start_session(self):
124125
"""Starts the conversation session.

0 commit comments

Comments
 (0)