fix: add macOS Homebrew Opus fallback and fix shutdown dict iteration
- Add Homebrew library path fallback when ctypes.util.find_library fails on macOS (Apple Silicon + Intel paths, guarded by platform check) - Fix RuntimeError in gateway stop() by iterating over dict copy - Update Opus tests to verify find_library-first + conditional fallback
This commit is contained in:
parent
c797314fcf
commit
44abe852fb
3 changed files with 33 additions and 11 deletions
|
|
@ -409,6 +409,19 @@ class DiscordAdapter(BasePlatformAdapter):
|
|||
if not discord.opus.is_loaded():
|
||||
import ctypes.util
|
||||
opus_path = ctypes.util.find_library("opus")
|
||||
# ctypes.util.find_library fails on macOS with Homebrew-installed libs,
|
||||
# so fall back to known Homebrew paths if needed.
|
||||
if not opus_path:
|
||||
import sys
|
||||
_homebrew_paths = (
|
||||
"/opt/homebrew/lib/libopus.dylib", # Apple Silicon
|
||||
"/usr/local/lib/libopus.dylib", # Intel Mac
|
||||
)
|
||||
if sys.platform == "darwin":
|
||||
for _hp in _homebrew_paths:
|
||||
if os.path.isfile(_hp):
|
||||
opus_path = _hp
|
||||
break
|
||||
if opus_path:
|
||||
try:
|
||||
discord.opus.load_opus(opus_path)
|
||||
|
|
|
|||
|
|
@ -754,7 +754,7 @@ class GatewayRunner:
|
|||
logger.info("Stopping gateway...")
|
||||
self._running = False
|
||||
|
||||
for platform, adapter in self.adapters.items():
|
||||
for platform, adapter in list(self.adapters.items()):
|
||||
try:
|
||||
await adapter.disconnect()
|
||||
logger.info("✓ %s disconnected", platform.value)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue