File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -276,7 +276,11 @@ def open(self):
276276 request_generator = _RequestQueueGenerator (
277277 self ._request_queue , initial_request = self ._initial_request
278278 )
279- call = self ._start_rpc (iter (request_generator ), metadata = self ._rpc_metadata )
279+ try :
280+ call = self ._start_rpc (iter (request_generator ), metadata = self ._rpc_metadata )
281+ except exceptions .GoogleAPICallError as exc :
282+ self ._on_call_done (exc )
283+ raise
280284
281285 request_generator .call = call
282286
Original file line number Diff line number Diff line change @@ -804,6 +804,20 @@ def test_wake_on_error(self):
804804 while consumer .is_active :
805805 pass
806806
807+ def test_rpc_callback_fires_when_consumer_start_fails (self ):
808+ expected_exception = exceptions .InvalidArgument ("test" )
809+ callback = mock .Mock (spec = ["__call__" ])
810+ rpc , _ = make_rpc ()
811+ bidi_rpc = bidi .BidiRpc (rpc )
812+ bidi_rpc .add_done_callback (callback )
813+ bidi_rpc ._start_rpc .side_effect = expected_exception
814+
815+ consumer = bidi .BackgroundConsumer (bidi_rpc , on_response = lambda : None )
816+
817+ consumer .start ()
818+
819+ assert callback .call_args .args [0 ] == expected_exception
820+
807821 def test_consumer_expected_error (self , caplog ):
808822 caplog .set_level (logging .DEBUG )
809823
You can’t perform that action at this time.
0 commit comments