Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/examples/example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1117,7 +1117,7 @@
"source": [
"my_organizations = await app_client.list_organizations()\n",
"MY_ORG_ID = my_organizations[0].id\n",
"my_locations = await app_client.list_locations(organization_id=MY_ORG_ID)\n",
"my_locations = await app_client.list_locations()\n",
"robots = []\n",
"\n",
"for location in my_locations:\n",
Expand Down
43 changes: 43 additions & 0 deletions src/viam/app/_logs.py
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()
Loading