Skip to content

Commit 7f9401b

Browse files
authored
refactor: optional event loop argument in IntegrationAPI constructor (#41)
If an event loop is not provided, it is automatically retrieved with `asyncio.get_event_loop()`. This allows easier client usage.
1 parent 344e6cb commit 7f9401b

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
_Changes in the next release_
1111

12+
### Changed
13+
- Optional event loop argument in IntegrationAPI constructor.
14+
1215
---
1316

1417
## v0.5.0 - 2025-12-17

ucapi/api.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,14 @@ class IntegrationAPI:
7575

7676
DEFAULT_VOICE_SESSION_TIMEOUT_S: int = 30
7777

78-
def __init__(self, loop: AbstractEventLoop):
78+
def __init__(self, loop: AbstractEventLoop | None = None):
7979
"""
8080
Create an integration driver API instance.
8181
82-
:param loop: event loop
82+
:param loop: optional event loop. The currently running event loop is used if
83+
not provided.
8384
"""
84-
self._loop = loop
85+
self._loop = loop if loop else asyncio.get_event_loop()
8586
self._events = AsyncIOEventEmitter(self._loop)
8687

8788
self._setup_handler: uc.SetupHandler | None = None

0 commit comments

Comments
 (0)