Skip to content

Commit 20ac2b4

Browse files
committed
Fix iterator convertion
1 parent 85882de commit 20ac2b4

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
* Fix exception for convert sync to async iterator
12
* Fixed start many sync writers/readers in parallel
23

34
## 3.3.0 ##

ydb/_grpc/grpcwrapper/common_utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def __next__(self):
112112
return item
113113

114114

115-
class SyncIteratorToAsyncIterator:
115+
class SyncToAsyncIterator:
116116
def __init__(self, sync_iterator: Iterator, executor: concurrent.futures.Executor):
117117
self._sync_iterator = sync_iterator
118118
self._executor = executor
@@ -124,8 +124,8 @@ async def __anext__(self):
124124
try:
125125
res = await to_thread(self._sync_iterator.__next__, executor=self._executor)
126126
return res
127-
except StopAsyncIteration:
128-
raise StopIteration()
127+
except StopIteration:
128+
raise StopAsyncIteration()
129129

130130

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

198198
stream_call = await to_thread(driver, requests_iterator, stub, method, executor=self._wait_executor)
199199
self._stream_call = stream_call
200-
self.from_server_grpc = SyncIteratorToAsyncIterator(stream_call.__iter__(), self._wait_executor)
200+
self.from_server_grpc = SyncToAsyncIterator(stream_call.__iter__(), self._wait_executor)
201201

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

0 commit comments

Comments
 (0)