Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicitly close memory object streams #1253

Merged
merged 1 commit into from
Jul 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ def __init__(self, sockets, *args, **kwargs):
send_stream, receive_stream = create_memory_object_stream(max_buffer_size=inf)
self._streams[socket] = {"send": send_stream, "receive": receive_stream}

def close(self):
for streams in self._streams.values():
for stream in streams.values():
stream.close()
self._streams.clear()

def send(self, socket, *args, **kwargs):
msg = super().send(socket, *args, **kwargs)
send_stream: MemoryObjectSendStream[Any] = self._streams[socket]["send"]
Expand Down Expand Up @@ -102,6 +108,7 @@ async def do_debug_request(self, msg):

def destroy(self):
self.stop()
self.session.close()
for socket in self.test_sockets:
socket.close()
self.context.destroy()
Expand Down
Loading