Skip to content

Commit 939e3e0

Browse files
authored
fix: Resolve asyncio loop mismatch error (#3)
2 parents 7fdf8e9 + 1170e0c commit 939e3e0

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

chzzk/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
__author__ = 'westreed'
44
__license__ = 'MIT'
55
__copyright__ = 'Copyright 2024-present westreed'
6-
__version__ = '0.1.1'
6+
__version__ = '0.1.2'
77

88
from typing import NamedTuple, Literal
99
from .chzzk import Chzzk
@@ -18,6 +18,6 @@ class VersionInfo(NamedTuple):
1818
serial: int
1919

2020

21-
version_info: VersionInfo = VersionInfo(major=0, minor=1, micro=1, releaselevel='alpha', serial=0)
21+
version_info: VersionInfo = VersionInfo(major=0, minor=1, micro=2, releaselevel='alpha', serial=0)
2222

2323
del NamedTuple, Literal, VersionInfo

chzzk/event/event_manager.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
class EventManager:
1212
def __init__(self, prefix: str, loop: Optional[asyncio.AbstractEventLoop] = None):
13-
self.loop: asyncio.AbstractEventLoop = loop or asyncio.get_event_loop()
13+
self.loop: Optional[asyncio.AbstractEventLoop] = loop
1414
self.prefix = prefix
1515
self._listeners: dict[str, list[tuple[asyncio.Future, Callable[..., bool]]]] = dict()
1616
self._extra_event: dict[str, list[Callable[..., Coroutine[Any, Any, Any]]]] = dict()
@@ -48,6 +48,7 @@ def wait_for(
4848
The number of seconds to wait before timing out and raising
4949
:exc:`asyncio.TimeoutError`.
5050
"""
51+
assert self.loop is not None, "Asyncio Loop is None."
5152
future = self.loop.create_future()
5253

5354
if check is None:
@@ -183,6 +184,7 @@ def _schedule_event(
183184
*args: Any,
184185
**kwargs: Any,
185186
) -> asyncio.Task:
187+
assert self.loop is not None, "Asyncio Loop is None."
186188
wrapped = self._run_event(coro, event_name, *args, **kwargs)
187189
# Schedules the task
188190
return self.loop.create_task(wrapped, name=f"chzzk: {event_name}")

0 commit comments

Comments
 (0)