facilitate manual call management (#7)
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,6 +2,7 @@
|
|||||||
env/
|
env/
|
||||||
__pycache__/
|
__pycache__/
|
||||||
*~
|
*~
|
||||||
|
venv
|
||||||
#*#
|
#*#
|
||||||
|
|
||||||
# Distribution / packaging
|
# Distribution / packaging
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ class DailyTransportService(EventHandler):
|
|||||||
token: str | None,
|
token: str | None,
|
||||||
bot_name: str,
|
bot_name: str,
|
||||||
duration: float = 10,
|
duration: float = 10,
|
||||||
|
min_others_count: int = 1,
|
||||||
):
|
):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.bot_name: str = bot_name
|
self.bot_name: str = bot_name
|
||||||
@@ -37,6 +38,7 @@ class DailyTransportService(EventHandler):
|
|||||||
self.token: str | None = token
|
self.token: str | None = token
|
||||||
self.duration: float = duration
|
self.duration: float = duration
|
||||||
self.expiration = time.time() + duration * 60
|
self.expiration = time.time() + duration * 60
|
||||||
|
self.min_others_count = min_others_count
|
||||||
|
|
||||||
# This queue is used to marshal frames from the async send queue to the thread that emits audio & video.
|
# This queue is used to marshal frames from the async send queue to the thread that emits audio & video.
|
||||||
# We need this to maintain the asynchronous behavior of asyncio queues -- to give async functions
|
# We need this to maintain the asynchronous behavior of asyncio queues -- to give async functions
|
||||||
@@ -224,14 +226,14 @@ class DailyTransportService(EventHandler):
|
|||||||
async def run(self) -> None:
|
async def run(self) -> None:
|
||||||
self.configure_daily()
|
self.configure_daily()
|
||||||
|
|
||||||
self.participant_left = False
|
self.do_shutdown = False
|
||||||
|
|
||||||
async_output_queue_marshal_task = asyncio.create_task(self.marshal_frames())
|
async_output_queue_marshal_task = asyncio.create_task(self.marshal_frames())
|
||||||
|
|
||||||
try:
|
try:
|
||||||
participant_count: int = len(self.client.participants())
|
participant_count: int = len(self.client.participants())
|
||||||
self.logger.info(f"{participant_count} participants in room")
|
self.logger.info(f"{participant_count} participants in room")
|
||||||
while time.time() < self.expiration and not self.participant_left and not self.stop_threads.is_set():
|
while time.time() < self.expiration and not self.do_shutdown and not self.stop_threads.is_set():
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.error(f"Exception {e}")
|
self.logger.error(f"Exception {e}")
|
||||||
@@ -270,8 +272,8 @@ class DailyTransportService(EventHandler):
|
|||||||
self.on_first_other_participant_joined()
|
self.on_first_other_participant_joined()
|
||||||
|
|
||||||
def on_participant_left(self, participant, reason):
|
def on_participant_left(self, participant, reason):
|
||||||
if len(self.client.participants()) < 2:
|
if len(self.client.participants()) < self.min_others_count + 1:
|
||||||
self.participant_left = True
|
self.do_shutdown = True
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def on_app_message(self, message, sender):
|
def on_app_message(self, message, sender):
|
||||||
|
|||||||
Reference in New Issue
Block a user