Skip to content

Commit

Permalink
join on the reader thread when closing the connection
Browse files Browse the repository at this point in the history
  • Loading branch information
mmerickel committed Jan 26, 2024
1 parent 2c86292 commit c3afd56
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/hupper/ipc.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ class Connection(object):

_packet_len = struct.Struct('Q')

send_lock = None
reader_thread = None
on_recv = lambda _: None

def __init__(self, r_fd, w_fd):
self.r_fd = r_fd
self.w_fd = w_fd
Expand Down Expand Up @@ -142,6 +146,8 @@ def close(self):

close_fd(w_fd)
close_fd(r_fd)
if self.reader_thread:
self.reader_thread.join()

def _recv_packet(self):
buf = io.BytesIO()
Expand Down
2 changes: 0 additions & 2 deletions tests/test_ipc.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ def echo(pipe):
pipe.send(msg)
msg = q.get()
pipe.close()
pipe.reader_thread.join()


def test_ipc_close():
Expand All @@ -31,6 +30,5 @@ def test_ipc_close():
assert c1_q.get() == "hello world"

c1.close()
c1.reader_thread.join()
finally:
proc.terminate()

0 comments on commit c3afd56

Please sign in to comment.