def handle_event(event): with state.condition: callbacks = _handle_event(event, state, response_deserializer) state.condition.notify_all() done = not state.due for callback in callbacks: callback() return done and state.fork_epoch >= cygrpc.get_fork_epoch()
def handle_event(event): with state.condition: callbacks = _handle_event(event, state, response_deserializer) state.condition.notify_all() done = not state.due for callback in callbacks: callback() if getattr(state, 'on_event_handler_callback', None) is not None: state.on_event_handler_callback(state) return done and state.fork_epoch >= cygrpc.get_fork_epoch()
def handle_event(event): with state.condition: callbacks = _handle_event(event, state, response_deserializer) state.condition.notify_all() done = not state.due for callback in callbacks: try: callback() except Exception as e: # pylint: disable=broad-except # NOTE(rbellevi): We suppress but log errors here so as not to # kill the channel spin thread. logging.error('Exception in callback %s: %s', repr( callback.func), repr(e)) return done and state.fork_epoch >= cygrpc.get_fork_epoch()
def __init__(self, due, initial_metadata, trailing_metadata, code, details): self.condition = threading.Condition() # The cygrpc.OperationType objects representing events due from the RPC's # completion queue. self.due = set(due) self.initial_metadata = initial_metadata self.response = None self.trailing_metadata = trailing_metadata self.code = code self.details = details self.debug_error_string = None # The semantics of grpc.Future.cancel and grpc.Future.cancelled are # slightly wonky, so they have to be tracked separately from the rest of the # result of the RPC. This field tracks whether cancellation was requested # prior to termination of the RPC. self.cancelled = False self.callbacks = [] self.fork_epoch = cygrpc.get_fork_epoch()