@@ -30,13 +30,15 @@ def __init__(
30
30
token : str | None ,
31
31
bot_name : str ,
32
32
duration : float = 10 ,
33
+ min_others_count : int = 1 ,
33
34
):
34
35
super ().__init__ ()
35
36
self .bot_name : str = bot_name
36
37
self .room_url : str = room_url
37
38
self .token : str | None = token
38
39
self .duration : float = duration
39
40
self .expiration = time .time () + duration * 60
41
+ self .min_others_count = min_others_count
40
42
41
43
# This queue is used to marshal frames from the async send queue to the thread that emits audio & video.
42
44
# We need this to maintain the asynchronous behavior of asyncio queues -- to give async functions
@@ -224,14 +226,14 @@ async def stop_when_done(self):
224
226
async def run (self ) -> None :
225
227
self .configure_daily ()
226
228
227
- self .participant_left = False
229
+ self .do_shutdown = False
228
230
229
231
async_output_queue_marshal_task = asyncio .create_task (self .marshal_frames ())
230
232
231
233
try :
232
234
participant_count : int = len (self .client .participants ())
233
235
self .logger .info (f"{ participant_count } participants in room" )
234
- while time .time () < self .expiration and not self .participant_left and not self .stop_threads .is_set ():
236
+ while time .time () < self .expiration and not self .do_shutdown and not self .stop_threads .is_set ():
235
237
await asyncio .sleep (1 )
236
238
except Exception as e :
237
239
self .logger .error (f"Exception { e } " )
@@ -270,8 +272,8 @@ def on_participant_joined(self, participant):
270
272
self .on_first_other_participant_joined ()
271
273
272
274
def on_participant_left (self , participant , reason ):
273
- if len (self .client .participants ()) < 2 :
274
- self .participant_left = True
275
+ if len (self .client .participants ()) < self . min_others_count + 1 :
276
+ self .do_shutdown = True
275
277
pass
276
278
277
279
def on_app_message (self , message , sender ):
0 commit comments