-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RSDK-3640] Implement More APP API's (#379)
- Loading branch information
Bashar
authored
Aug 17, 2023
1 parent
13a8d88
commit 69487f4
Showing
12 changed files
with
1,100 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import sys | ||
|
||
if sys.version_info >= (3, 9): | ||
from collections.abc import AsyncIterator | ||
else: | ||
from typing import AsyncIterator | ||
|
||
from typing import Protocol, TypeVar | ||
|
||
LogsType = TypeVar("LogsType", covariant=True) | ||
|
||
|
||
class _LogsStream(Protocol[LogsType]): | ||
async def next(self) -> LogsType: | ||
... | ||
|
||
async def close(self): | ||
... | ||
|
||
def __aiter__(self): | ||
return self | ||
|
||
async def __anext__(self) -> LogsType: | ||
return await self.next() | ||
|
||
|
||
class _LogsStreamWithIterator(_LogsStream[LogsType]): | ||
_stream: AsyncIterator[LogsType] | ||
|
||
def __init__(self, stream: AsyncIterator[LogsType]): | ||
self._stream = stream | ||
|
||
async def next(self) -> LogsType: | ||
return await self._stream.__anext__() | ||
|
||
def __aiter__(self): | ||
return self._stream | ||
|
||
async def __anext__(self) -> LogsType: | ||
return await self._stream.__anext__() | ||
|
||
async def close(self): | ||
return await super().close() |
Oops, something went wrong.