Skip to content

Commit

Permalink
Move _should_stop initialization to __init__ (#426)
Browse files Browse the repository at this point in the history
Avoid using mutable default values for _should_stop by initializing it in the __init__ method to ensure instance-level independence.
  • Loading branch information
tudor11l authored Dec 9, 2024
1 parent 0a5a4e0 commit c19ad6e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/elevenlabs/conversational_ai/conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class Conversation:
callback_latency_measurement: Optional[Callable[[int], None]]

_thread: Optional[threading.Thread] = None
_should_stop: threading.Event = threading.Event()
_should_stop: threading.Event
_conversation_id: Optional[str] = None
_last_interrupt_id: int = 0

Expand Down Expand Up @@ -119,6 +119,7 @@ def __init__(
self.callback_agent_response_correction = callback_agent_response_correction
self.callback_user_transcript = callback_user_transcript
self.callback_latency_measurement = callback_latency_measurement
self._should_stop = threading.Event()

def start_session(self):
"""Starts the conversation session.
Expand Down

0 comments on commit c19ad6e

Please sign in to comment.