20 _NOT_YET_OBSERVED = object()
22 _LOGGER = logging.getLogger(__name__)
26 return handler.cancel(grpc.StatusCode.CANCELLED,
'Locally cancelled!')
30 return handler.is_active()
34 raise NotImplementedError()
38 return handler.add_callback(callback)
42 return handler.initial_metadata()
46 trailing_metadata, unused_code, unused_details = handler.termination()
47 return trailing_metadata
51 unused_trailing_metadata, code, unused_details = handler.termination()
56 unused_trailing_metadata, unused_code, details = handler.termination()
121 read = handler.take_response()
122 if read.code
is None:
124 elif read.code
is grpc.StatusCode.OK:
125 raise StopIteration()
139 with extras.condition:
140 if handler.cancel(grpc.StatusCode.CANCELLED,
'Locally cancelled!'):
141 extras.cancelled =
True
148 with extras.condition:
149 return extras.cancelled
153 return handler.is_active()
157 return not handler.is_active()
161 with extras.condition:
162 if extras.unary_response
is _NOT_YET_OBSERVED:
163 read = handler.take_response()
164 if read.code
is None:
165 extras.unary_response = read.response
170 return extras.unary_response
174 raise NotImplementedError(
'TODO!')
178 raise NotImplementedError(
'TODO!')
182 adapted_callback =
lambda:
callback(future)
183 if not handler.add_callback(adapted_callback):
244 request =
next(request_iterator)
245 added = handler.add_request(request)
248 except StopIteration:
249 handler.close_requests()
252 details =
'Exception iterating requests!'
253 _LOGGER.exception(details)
254 handler.cancel(grpc.StatusCode.UNKNOWN, details)
256 consumption = threading.Thread(target=_consume)
261 read = handler.take_response()
262 if read.code
is None:
263 unused_trailing_metadata, code, unused_details = handler.termination()
264 if code
is grpc.StatusCode.OK:
273 read = handler.take_response()
274 if read.code
is None:
275 unused_trailing_metadata, code, unused_details = handler.termination()
276 if code
is grpc.StatusCode.OK:
277 return read.response,
_Call(handler)