5555class Client (BaseApiClient [dispatch_pb2_grpc .MicrogridDispatchServiceStub ]):
5656 """Dispatch API client."""
5757
58- streams : dict [
59- int , GrpcStreamBroadcaster [StreamMicrogridDispatchesResponse , DispatchEvent ]
60- ] = {}
61- """A dictionary of streamers, keyed by microgrid_id."""
62-
6358 def __init__ (
6459 self ,
6560 * ,
@@ -91,6 +86,10 @@ def __init__(
9186 ),
9287 )
9388 self ._metadata = (("key" , key ),)
89+ self ._streams : dict [
90+ int , GrpcStreamBroadcaster [StreamMicrogridDispatchesResponse , DispatchEvent ]
91+ ] = {}
92+ """A dictionary of streamers, keyed by microgrid_id."""
9493
9594 @property
9695 def stub (self ) -> dispatch_pb2_grpc .MicrogridDispatchServiceAsyncStub :
@@ -225,11 +224,11 @@ def _get_stream(
225224 self , microgrid_id : int
226225 ) -> GrpcStreamBroadcaster [StreamMicrogridDispatchesResponse , DispatchEvent ]:
227226 """Get an instance to the streaming helper."""
228- broadcaster = self .streams .get (microgrid_id )
227+ broadcaster = self ._streams .get (microgrid_id )
229228 # pylint: disable=protected-access
230229 if broadcaster is not None and broadcaster ._channel .is_closed :
231230 # pylint: enable=protected-access
232- del self .streams [microgrid_id ]
231+ del self ._streams [microgrid_id ]
233232 broadcaster = None
234233 if broadcaster is None :
235234 request = StreamMicrogridDispatchesRequest (microgrid_id = microgrid_id )
@@ -244,7 +243,7 @@ def _get_stream(
244243 transform = DispatchEvent .from_protobuf ,
245244 retry_strategy = LinearBackoff (interval = 1 , limit = 0 ),
246245 )
247- self .streams [microgrid_id ] = broadcaster
246+ self ._streams [microgrid_id ] = broadcaster
248247
249248 return broadcaster
250249
0 commit comments