Skip to content

Commit

Permalink
fix: 🐛 fixed type lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Sube-mm committed Nov 21, 2024
1 parent 509e8fb commit f69f830
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion broadcaster/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ async def subscribe(self, channel: str, history: int | None = None) -> AsyncIter
try:
current_id = await self._backend.get_current_channel_id(channel)
self._backend._ready.clear()
async for message in self._backend.get_history_messages(channel, current_id, history):
for message in await self._backend.get_history_messages(channel, current_id, history):
queue.put_nowait(message)
self._subscribers[channel].add(queue)
finally:
Expand Down
2 changes: 1 addition & 1 deletion broadcaster/backends/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ async def get_history_messages(
channel: str,
msg_id: int | bytes | str | memoryview,
count: int | None = None,
) -> AsyncGenerator[Event, None]: ...
) -> list[Event]: ...
10 changes: 6 additions & 4 deletions broadcaster/backends/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ async def next_published(self) -> Event:
async def get_current_channel_id(self, channel: str) -> int | bytes | str | memoryview:
try:
info = await self._consumer.xinfo_stream(channel)
last_id = info["last-generated-id"]
last_id: int = info["last-generated-id"]
except redis.ResponseError:
last_id = "0"
return last_id
Expand All @@ -179,10 +179,12 @@ async def get_history_messages(
channel: str,
msg_id: int | bytes | str | memoryview,
count: int | None = None,
) -> typing.AsyncGenerator[Event, None]:
) -> list[Event]:
messages = await self._consumer.xrevrange(channel, max=msg_id, count=count)
for _, message in reversed(messages or []):
yield Event(
return [
Event(
channel=channel,
message=message.get(b"message", b"").decode("utf-8"),
)
for _, message in reversed(messages or [])
]

0 comments on commit f69f830

Please sign in to comment.