11import asyncio
22import concurrent .futures
33import typing
4- from typing import List , Union , Iterable , Optional , Coroutine
4+ from typing import List , Union , Iterable , Optional
55
66from ydb ._grpc .grpcwrapper .common_utils import SupportedDriverType
77from ydb ._topic_common .common import _get_shared_event_loop , CallFromSyncToAsync
@@ -24,11 +24,11 @@ class TopicReaderSync:
2424 _closed : bool
2525
2626 def __init__ (
27- self ,
28- driver : SupportedDriverType ,
29- settings : PublicReaderSettings ,
30- * ,
31- eventloop : Optional [asyncio .AbstractEventLoop ] = None ,
27+ self ,
28+ driver : SupportedDriverType ,
29+ settings : PublicReaderSettings ,
30+ * ,
31+ eventloop : Optional [asyncio .AbstractEventLoop ] = None ,
3232 ):
3333 self ._closed = False
3434
@@ -70,7 +70,7 @@ async def sessions_stat(self) -> List[SessionStat]:
7070 raise NotImplementedError ()
7171
7272 def messages (
73- self , * , timeout : Union [float , None ] = None
73+ self , * , timeout : Union [float , None ] = None
7474 ) -> Iterable [PublicMessage ]:
7575 """
7676 todo?
@@ -104,11 +104,11 @@ def async_wait_message(self) -> concurrent.futures.Future:
104104 raise NotImplementedError ()
105105
106106 def batches (
107- self ,
108- * ,
109- max_messages : Union [int , None ] = None ,
110- max_bytes : Union [int , None ] = None ,
111- timeout : Union [float , None ] = None ,
107+ self ,
108+ * ,
109+ max_messages : Union [int , None ] = None ,
110+ max_bytes : Union [int , None ] = None ,
111+ timeout : Union [float , None ] = None ,
112112 ) -> Iterable [PublicBatch ]:
113113 """
114114 Block until receive new batch.
@@ -120,11 +120,11 @@ def batches(
120120 raise NotImplementedError ()
121121
122122 def receive_batch (
123- self ,
124- * ,
125- max_messages : typing .Union [int , None ] = None ,
126- max_bytes : typing .Union [int , None ] = None ,
127- timeout : Union [float , None ] = None ,
123+ self ,
124+ * ,
125+ max_messages : typing .Union [int , None ] = None ,
126+ max_bytes : typing .Union [int , None ] = None ,
127+ timeout : Union [float , None ] = None ,
128128 ) -> Union [PublicBatch , None ]:
129129 """
130130 Get one messages batch from reader
@@ -136,10 +136,15 @@ def receive_batch(
136136 self ._check_closed ()
137137
138138 return self ._caller .safe_call_with_result (
139- self ._async_reader .receive_batch (max_messages = max_messages , max_bytes = max_bytes ),
140- timeout )
141-
142- def commit (self , mess : typing .Union [datatypes .PublicMessage , datatypes .PublicBatch ]):
139+ self ._async_reader .receive_batch (
140+ max_messages = max_messages , max_bytes = max_bytes
141+ ),
142+ timeout ,
143+ )
144+
145+ def commit (
146+ self , mess : typing .Union [datatypes .PublicMessage , datatypes .PublicBatch ]
147+ ):
143148 """
144149 Put commit message to internal buffer.
145150
@@ -151,7 +156,7 @@ def commit(self, mess: typing.Union[datatypes.PublicMessage, datatypes.PublicBat
151156 self ._caller .call_sync (self ._async_reader .commit (mess ))
152157
153158 def commit_with_ack (
154- self , mess : ICommittable , timeout : typing .Union [int , float , None ] = None
159+ self , mess : ICommittable , timeout : typing .Union [int , float , None ] = None
155160 ) -> Union [CommitResult , List [CommitResult ]]:
156161 """
157162 write commit message to a buffer and wait ack from the server.
@@ -160,15 +165,21 @@ def commit_with_ack(
160165 """
161166 self ._check_closed ()
162167
163- return self ._caller .unsafe_call_with_result (self ._async_reader .commit_with_ack (mess ), timeout )
168+ return self ._caller .unsafe_call_with_result (
169+ self ._async_reader .commit_with_ack (mess ), timeout
170+ )
164171
165- def async_commit_with_ack (self , mess : typing .Union [datatypes .PublicMessage , datatypes .PublicBatch ]) -> concurrent .futures .Future :
172+ def async_commit_with_ack (
173+ self , mess : typing .Union [datatypes .PublicMessage , datatypes .PublicBatch ]
174+ ) -> concurrent .futures .Future :
166175 """
167176 write commit message to a buffer and return Future for wait result.
168177 """
169178 self ._check_closed ()
170179
171- return self ._caller .unsafe_call_with_future (self ._async_reader .commit_with_ack (mess ))
180+ return self ._caller .unsafe_call_with_future (
181+ self ._async_reader .commit_with_ack (mess )
182+ )
172183
173184 def async_flush (self ) -> concurrent .futures .Future :
174185 """
0 commit comments