Skip to content

Commit 5d2ffaa

Browse files
authored
Fix memory leaks in greengrasscoreipc (#186)
- Update awscrt to fix leaking headers - Break circular references in evenstreamrpc so garbage collector can clean them up
1 parent 7f8a609 commit 5d2ffaa

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

awsiot/eventstreamrpc.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -611,8 +611,8 @@ def __init__(self, stream_handler: StreamResponseHandler, shape_index: ShapeInde
611611
self._closed_future.set_running_or_notify_cancel() # prevent cancel
612612
self._initial_response_future = Future()
613613
self._initial_response_future.set_running_or_notify_cancel() # prevent cancel
614-
self._protocol_handler = _ProtocolContinuationHandler(self)
615-
self._continuation = connection._new_stream(self._protocol_handler)
614+
protocol_handler = _ProtocolContinuationHandler(self)
615+
self._continuation = connection._new_stream(protocol_handler)
616616

617617
def _activate(self, request: Shape) -> Future:
618618
headers = [Header.from_string(CONTENT_TYPE_HEADER,
@@ -805,6 +805,9 @@ def on_continuation_message(self, *args, **kwargs):
805805

806806
def on_continuation_closed(self, *args, **kwargs):
807807
self.operation._on_continuation_closed(*args, **kwargs)
808+
# break circular reference between: ClientOperation, _ProtocolContinuationHandler, ClientContinuation
809+
# so that garbage collector can clean them up
810+
self.operation = None
808811

809812

810813
class Client:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"Operating System :: OS Independent",
2020
],
2121
install_requires=[
22-
'awscrt==0.11.8',
22+
'awscrt==0.11.12',
2323
],
2424
python_requires='>=3.5',
2525
)

0 commit comments

Comments
 (0)