Skip to content

Commit

Permalink
Merge pull request grpc#1059 from nathanielmanistaatgoogle/python-ref…
Browse files Browse the repository at this point in the history
…actoring

Add at CANCELLATION back-to-front ticket kind
  • Loading branch information
soltanmm committed Mar 17, 2015
2 parents 758a0c2 + affe916 commit 18c7a36
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/python/src/grpc/_adapter/rear.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,7 @@ def _on_finish_event(self, operation_id, event, rpc_state):
if event.status.code is _low.Code.OK:
kind = tickets.BackToFrontPacket.Kind.COMPLETION
elif event.status.code is _low.Code.CANCELLED:
# TODO(issue 752): Use a CANCELLATION ticket kind here.
kind = tickets.BackToFrontPacket.Kind.SERVICER_FAILURE
kind = tickets.BackToFrontPacket.Kind.CANCELLATION
elif event.status.code is _low.Code.EXPIRED:
kind = tickets.BackToFrontPacket.Kind.EXPIRATION
else:
Expand Down
4 changes: 3 additions & 1 deletion src/python/src/grpc/framework/base/packets/_reception.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,9 @@ def _abortive(self, packet):
A base_interfaces.Outcome value describing operation abortion if the
packet is abortive or None if the packet is not abortive.
"""
if packet.kind is packets.BackToFrontPacket.Kind.EXPIRATION:
if packet.kind is packets.BackToFrontPacket.Kind.CANCELLATION:
return base_interfaces.Outcome.CANCELLED
elif packet.kind is packets.BackToFrontPacket.Kind.EXPIRATION:
return base_interfaces.Outcome.EXPIRED
elif packet.kind is packets.BackToFrontPacket.Kind.SERVICER_FAILURE:
return base_interfaces.Outcome.SERVICER_FAILURE
Expand Down
2 changes: 2 additions & 0 deletions src/python/src/grpc/framework/base/packets/_transmission.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
}

_ABORTION_OUTCOME_TO_BACK_TO_FRONT_PACKET_KIND = {
interfaces.Outcome.CANCELLED:
packets.BackToFrontPacket.Kind.CANCELLATION,
interfaces.Outcome.EXPIRED:
packets.BackToFrontPacket.Kind.EXPIRATION,
interfaces.Outcome.RECEPTION_FAILURE:
Expand Down
2 changes: 1 addition & 1 deletion src/python/src/grpc/framework/base/packets/packets.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ class BackToFrontPacket(
class Kind(enum.Enum):
"""Identifies the overall kind of a BackToFrontPacket."""

# TODO(issue 752): Add CANCELLATION.
CONTINUATION = 'continuation'
COMPLETION = 'completion'
CANCELLATION = 'cancellation'
EXPIRATION = 'expiration'
SERVICER_FAILURE = 'servicer failure'
SERVICED_FAILURE = 'serviced failure'
Expand Down

0 comments on commit 18c7a36

Please sign in to comment.