Skip to content

Commit

Permalink
Explicitly close memory object streams (#1253)
Browse files Browse the repository at this point in the history
  • Loading branch information
ianthomas23 authored Jul 1, 2024
1 parent 3116467 commit 5641346
Showing 1 changed file with 7 additions and 0 deletions.
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

0 comments on commit 5641346

Please sign in to comment.