Skip to content

Commit

Permalink
Merge pull request #292 Fix exception for convert sync to async iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
rekby authored May 4, 2023
2 parents 0255eb9 + 20ac2b4 commit e82c255
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
* Fix exception for convert sync to async iterator
* Fixed start many sync writers/readers in parallel

## 3.3.0 ##
Expand Down
8 changes: 4 additions & 4 deletions ydb/_grpc/grpcwrapper/common_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def __next__(self):
return item


class SyncIteratorToAsyncIterator:
class SyncToAsyncIterator:
def __init__(self, sync_iterator: Iterator, executor: concurrent.futures.Executor):
self._sync_iterator = sync_iterator
self._executor = executor
Expand All @@ -124,8 +124,8 @@ async def __anext__(self):
try:
res = await to_thread(self._sync_iterator.__next__, executor=self._executor)
return res
except StopAsyncIteration:
raise StopIteration()
except StopIteration:
raise StopAsyncIteration()


class IGrpcWrapperAsyncIO(abc.ABC):
Expand Down Expand Up @@ -197,7 +197,7 @@ async def _start_sync_driver(self, driver: ydb.Driver, stub, method):

stream_call = await to_thread(driver, requests_iterator, stub, method, executor=self._wait_executor)
self._stream_call = stream_call
self.from_server_grpc = SyncIteratorToAsyncIterator(stream_call.__iter__(), self._wait_executor)
self.from_server_grpc = SyncToAsyncIterator(stream_call.__iter__(), self._wait_executor)

async def receive(self) -> Any:
# todo handle grpc exceptions and convert it to internal exceptions
Expand Down

0 comments on commit e82c255

Please sign in to comment.