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/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 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/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/src/hupper/watchman.py b/src/hupper/watchman.py index a164574..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: @@ -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 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() 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