File tree 2 files changed +9
-5
lines changed
src/rai_core/rai/agents/langchain 2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -209,6 +209,7 @@ def _run_loop(self):
209
209
self ._run_agent ()
210
210
211
211
def stop (self ):
212
+ """Stop the agent's execution loop."""
212
213
self ._stop_event .set ()
213
214
self ._interrupt_event .set ()
214
215
self ._agent_ready_event .wait ()
@@ -217,6 +218,7 @@ def stop(self):
217
218
self ._thread .join ()
218
219
self ._thread = None
219
220
self .logger .info ("Agent stopped" )
221
+ self ._stop_event .clear ()
220
222
221
223
@staticmethod
222
224
def _apply_reduction_behavior (
Original file line number Diff line number Diff line change @@ -165,16 +165,18 @@ def process_aggregator(
165
165
166
166
def stop (self ):
167
167
"""Stop the agent's execution loop."""
168
- self .logger .info ("Stopping the agent. Please wait..." )
169
168
self ._stop_event .set ()
170
- if self .thread is not None :
171
- self .thread .join ()
172
- self .thread = None
169
+ self ._interrupt_event .set ()
170
+ self ._agent_ready_event .wait ()
171
+ if self ._thread is not None :
172
+ self .logger .info ("Stopping the agent. Please wait..." )
173
+ self ._thread .join ()
174
+ self ._thread = None
173
175
if self ._aggregation_thread is not None :
174
176
self ._aggregation_thread .join ()
175
177
self ._aggregation_thread = None
176
- self ._stop_event .clear ()
177
178
for callback_id in self ._registered_callbacks :
178
179
self ._connector .unregister_callback (callback_id )
180
+ self ._stop_event .clear ()
179
181
self ._connector .shutdown ()
180
182
self .logger .info ("Agent stopped" )
You can’t perform that action at this time.
0 commit comments