Skip to content

Commit

Permalink
handle StreamReset event
Browse files Browse the repository at this point in the history
fixes cancel_after_first_response interop test
  • Loading branch information
mattbennett committed Jan 16, 2019
1 parent 8292136 commit 13d959c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions nameko_grpc/connection.py
Expand Up @@ -13,6 +13,7 @@
ResponseReceived,
SettingsAcknowledged,
StreamEnded,
StreamReset,
TrailersReceived,
WindowUpdated,
)
Expand Down Expand Up @@ -79,6 +80,8 @@ def run_forever(self):
self.data_received(event)
elif isinstance(event, StreamEnded):
self.stream_ended(event)
elif isinstance(event, StreamReset):
self.stream_reset(event)
elif isinstance(event, WindowUpdated):
self.window_updated(event)
elif isinstance(event, RemoteSettingsChanged):
Expand Down Expand Up @@ -160,6 +163,16 @@ def stream_ended(self, event):
if receive_stream:
receive_stream.close()

def stream_reset(self, event):
""" Called when an incoming stream is reset.
Close any `ReceiveStream` that was opened for this stream.
"""
log.debug("stream reset, stream %s", event.stream_id)
receive_stream = self.receive_streams.pop(event.stream_id, None)
if receive_stream:
receive_stream.close()

def settings_changed(self, event):
log.debug("settings changed")

Expand Down
2 changes: 1 addition & 1 deletion test/test_interop.py
Expand Up @@ -56,7 +56,7 @@ def server(request, server_type):
("rpc_soak", False, False),
("channel_soak", False, False),
("cancel_after_begin", False, False),
("cancel_after_first_response", False, True), # nameko fails, not sure why
("cancel_after_first_response", False, False),
("custom_metadata", False, False),
("status_code_and_message", False, False),
],
Expand Down

0 comments on commit 13d959c

Please sign in to comment.