Only initialize Daily once (#5)
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import inspect
|
import inspect
|
||||||
import logging
|
import logging
|
||||||
|
import threading
|
||||||
import time
|
import time
|
||||||
import types
|
import types
|
||||||
|
|
||||||
@@ -21,6 +22,8 @@ from daily import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
class DailyTransportService(EventHandler):
|
class DailyTransportService(EventHandler):
|
||||||
|
_daily_initialized = False
|
||||||
|
_lock = threading.Lock()
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
room_url: str,
|
room_url: str,
|
||||||
@@ -114,7 +117,11 @@ class DailyTransportService(EventHandler):
|
|||||||
return decorator
|
return decorator
|
||||||
|
|
||||||
def configure_daily(self):
|
def configure_daily(self):
|
||||||
Daily.init()
|
# Only initialize Daily once
|
||||||
|
if not DailyTransportService._daily_initialized:
|
||||||
|
with DailyTransportService._lock:
|
||||||
|
Daily.init()
|
||||||
|
DailyTransportService._daily_initialized = True
|
||||||
self.client = CallClient(event_handler=self)
|
self.client = CallClient(event_handler=self)
|
||||||
|
|
||||||
if self.mic_enabled:
|
if self.mic_enabled:
|
||||||
|
|||||||
Reference in New Issue
Block a user