From 3d61949690fbcfb40330adb61b82b491ab9c027e Mon Sep 17 00:00:00 2001 From: Michael Merickel Date: Fri, 26 Jan 2024 01:32:59 -0700 Subject: [PATCH 1/5] support python 3.12 --- .github/workflows/ci-tests.yml | 1 + setup.cfg | 1 + tox.ini | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index 0ee68cb..0f1bdd6 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -21,6 +21,7 @@ jobs: - "3.9" - "3.10" - "3.11" + - "3.12" - "pypy-3.8" os: - "ubuntu-latest" diff --git a/setup.cfg b/setup.cfg index 0bec643..3914d04 100644 --- a/setup.cfg +++ b/setup.cfg @@ -33,6 +33,7 @@ classifiers = Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 Programming Language :: Python :: 3.11 + Programming Language :: Python :: 3.12 Programming Language :: Python :: Implementation :: CPython Programming Language :: Python :: Implementation :: PyPy diff --git a/tox.ini b/tox.ini index 833e93d..538a6ad 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,7 @@ [tox] envlist = lint, - py37,py38,py39,py310,py311,pypy3, + py37,py38,py39,py310,py311,py312,pypy3, docs,coverage isolated_build = true From e0e3a6314772052722a8946fbe62f706440629b5 Mon Sep 17 00:00:00 2001 From: Michael Merickel Date: Fri, 26 Jan 2024 01:34:33 -0700 Subject: [PATCH 2/5] fix line length --- src/hupper/watchman.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hupper/watchman.py b/src/hupper/watchman.py index a164574..05116b4 100644 --- a/src/hupper/watchman.py +++ b/src/hupper/watchman.py @@ -194,7 +194,8 @@ def _readline(self): b = self._sock.recv(4096) if not b: self.logger.error( - 'Lost connection to watchman. No longer watching for changes.' + 'Lost connection to watchman. No longer watching for' + ' changes.' ) self.stop() raise socket.timeout From 1f2762dc8c840ae7fe876df62e774c098e275486 Mon Sep 17 00:00:00 2001 From: Michael Merickel Date: Fri, 26 Jan 2024 01:36:07 -0700 Subject: [PATCH 3/5] move public method to the top --- src/hupper/watchman.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hupper/watchman.py b/src/hupper/watchman.py index 05116b4..8ed461b 100644 --- a/src/hupper/watchman.py +++ b/src/hupper/watchman.py @@ -79,6 +79,10 @@ def join(self): finally: self._close_sock() + def stop(self): + self.enabled = False + self._close_sock() + def run(self): while self.enabled: try: @@ -138,10 +142,6 @@ def _is_unilateral(self, result): return True return False - def stop(self): - self.enabled = False - self._close_sock() - def _close_sock(self): if self._sock: try: From 2c8629281dc56a820d0f4a31bf9126eaf0b1038c Mon Sep 17 00:00:00 2001 From: Michael Merickel Date: Fri, 26 Jan 2024 01:36:34 -0700 Subject: [PATCH 4/5] update changelog --- CHANGES.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 77e6008..b5e4e04 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,8 @@ unreleased ========== +- Add support for Python 3.12. + - Fix a blocking issue when shutting down on Windows. - Fix a broken socket that sometimes occurs when reloading due to sockets being From c3afd5647e7588b4a2acb8ca1dd3a40fa3297bef Mon Sep 17 00:00:00 2001 From: Michael Merickel Date: Fri, 26 Jan 2024 01:42:22 -0700 Subject: [PATCH 5/5] join on the reader thread when closing the connection --- src/hupper/ipc.py | 6 ++++++ tests/test_ipc.py | 2 -- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/hupper/ipc.py b/src/hupper/ipc.py index 1f07dc9..ec2767e 100644 --- a/src/hupper/ipc.py +++ b/src/hupper/ipc.py @@ -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 @@ -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() diff --git a/tests/test_ipc.py b/tests/test_ipc.py index 76d559c..9b33f51 100644 --- a/tests/test_ipc.py +++ b/tests/test_ipc.py @@ -11,7 +11,6 @@ def echo(pipe): pipe.send(msg) msg = q.get() pipe.close() - pipe.reader_thread.join() def test_ipc_close(): @@ -31,6 +30,5 @@ def test_ipc_close(): assert c1_q.get() == "hello world" c1.close() - c1.reader_thread.join() finally: proc.terminate()