Merge pull request #1059 from nathanielmanistaatgoogle/python-refactoring
Add at CANCELLATION back-to-front ticket kind
diff --git a/src/python/src/grpc/_adapter/rear.py b/src/python/src/grpc/_adapter/rear.py
index 38936ed..eee008e 100644
--- a/src/python/src/grpc/_adapter/rear.py
+++ b/src/python/src/grpc/_adapter/rear.py
@@ -191,8 +191,7 @@
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:
diff --git a/src/python/src/grpc/framework/base/packets/_reception.py b/src/python/src/grpc/framework/base/packets/_reception.py
index 6970959..ef10c7f 100644
--- a/src/python/src/grpc/framework/base/packets/_reception.py
+++ b/src/python/src/grpc/framework/base/packets/_reception.py
@@ -244,7 +244,9 @@
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
diff --git a/src/python/src/grpc/framework/base/packets/_transmission.py b/src/python/src/grpc/framework/base/packets/_transmission.py
index 9922213..1b18204 100644
--- a/src/python/src/grpc/framework/base/packets/_transmission.py
+++ b/src/python/src/grpc/framework/base/packets/_transmission.py
@@ -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:
diff --git a/src/python/src/grpc/framework/base/packets/packets.py b/src/python/src/grpc/framework/base/packets/packets.py
index d3f9a92..1b14048 100644
--- a/src/python/src/grpc/framework/base/packets/packets.py
+++ b/src/python/src/grpc/framework/base/packets/packets.py
@@ -108,9 +108,9 @@
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'