From d3d78d9176a3e0b6e28cea23983938997d545b87 Mon Sep 17 00:00:00 2001 From: "Yves.Duprat" Date: Fri, 1 May 2026 18:24:42 +0200 Subject: [PATCH 1/6] Initial commit --- Lib/multiprocessing/synchronize.py | 9 ++++++++- Lib/test/_test_multiprocessing.py | 18 +++++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/Lib/multiprocessing/synchronize.py b/Lib/multiprocessing/synchronize.py index 9188114ae284c7..3f5f4fa27b5425 100644 --- a/Lib/multiprocessing/synchronize.py +++ b/Lib/multiprocessing/synchronize.py @@ -369,7 +369,8 @@ def wait(self, timeout=None): def __repr__(self): set_status = 'set' if self.is_set() else 'unset' - return f"<{type(self).__qualname__} at {id(self):#x} {set_status}>" + return f"<{type(self).__qualname__}({set_status})>" + # # Barrier # @@ -409,3 +410,9 @@ def _count(self): @_count.setter def _count(self, value): self._array[1] = value + + def __repr__(self): + name = self.__class__.__qualname__ + if self.broken: + return f"<{name}(broken)>" + return (f"<{name}(waiters={self.n_waiting}/{self.parties})>") diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py index 580d9f2b32544e..bdc6a6765e2a5e 100644 --- a/Lib/test/_test_multiprocessing.py +++ b/Lib/test/_test_multiprocessing.py @@ -2133,11 +2133,11 @@ def test_event(self): def test_repr(self) -> None: event = self.Event() if self.TYPE == 'processes': - self.assertRegex(repr(event), r"") + self.assertIn("", repr(event)) event.set() - self.assertRegex(repr(event), r"") + self.assertIn("", repr(event)) event.clear() - self.assertRegex(repr(event), r"") + self.assertIn("", repr(event)) elif self.TYPE == 'manager': self.assertRegex(repr(event), r" Date: Wed, 6 May 2026 08:44:15 +0000 Subject: [PATCH 2/6] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Library/2026-05-06-08-44-03.gh-issue-149399.zqSWNs.rst | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2026-05-06-08-44-03.gh-issue-149399.zqSWNs.rst diff --git a/Misc/NEWS.d/next/Library/2026-05-06-08-44-03.gh-issue-149399.zqSWNs.rst b/Misc/NEWS.d/next/Library/2026-05-06-08-44-03.gh-issue-149399.zqSWNs.rst new file mode 100644 index 00000000000000..d3f9ec614354ac --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-05-06-08-44-03.gh-issue-149399.zqSWNs.rst @@ -0,0 +1,4 @@ +Change :meth:`__rep__` of :class:`multiprocessing.Event` +and add a :meth:`__repr__` in the :class:`multioprocessing.Barrier` +in order to be consistent with the other synchronization primitives +of :mod:`multiprocessing` module. From 67c9694e5c94825dc6a905e49eff7771378e925f Mon Sep 17 00:00:00 2001 From: Duprat Date: Wed, 6 May 2026 11:53:43 +0200 Subject: [PATCH 3/6] Fix nits --- .../Library/2026-05-06-08-44-03.gh-issue-149399.zqSWNs.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Misc/NEWS.d/next/Library/2026-05-06-08-44-03.gh-issue-149399.zqSWNs.rst b/Misc/NEWS.d/next/Library/2026-05-06-08-44-03.gh-issue-149399.zqSWNs.rst index d3f9ec614354ac..9c40c709766f72 100644 --- a/Misc/NEWS.d/next/Library/2026-05-06-08-44-03.gh-issue-149399.zqSWNs.rst +++ b/Misc/NEWS.d/next/Library/2026-05-06-08-44-03.gh-issue-149399.zqSWNs.rst @@ -1,4 +1,4 @@ -Change :meth:`__rep__` of :class:`multiprocessing.Event` -and add a :meth:`__repr__` in the :class:`multioprocessing.Barrier` +Change the :meth:`__repr__` of :class:`multiprocessing.Event` +and add a :meth:`__repr__` to the :class:`multiprocessing.Barrier` in order to be consistent with the other synchronization primitives -of :mod:`multiprocessing` module. +of :mod:`multiprocessing` module. From 39a3e5a61475358ad8c9921c4e8c0f84c6b0d7f9 Mon Sep 17 00:00:00 2001 From: Duprat Date: Wed, 6 May 2026 12:01:05 +0200 Subject: [PATCH 4/6] Fix bad ref in news --- .../next/Library/2026-05-06-08-44-03.gh-issue-149399.zqSWNs.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2026-05-06-08-44-03.gh-issue-149399.zqSWNs.rst b/Misc/NEWS.d/next/Library/2026-05-06-08-44-03.gh-issue-149399.zqSWNs.rst index 9c40c709766f72..9a06d295d4471d 100644 --- a/Misc/NEWS.d/next/Library/2026-05-06-08-44-03.gh-issue-149399.zqSWNs.rst +++ b/Misc/NEWS.d/next/Library/2026-05-06-08-44-03.gh-issue-149399.zqSWNs.rst @@ -1,4 +1,4 @@ Change the :meth:`__repr__` of :class:`multiprocessing.Event` -and add a :meth:`__repr__` to the :class:`multiprocessing.Barrier` +and add a ``__repr__`` method to the :class:`multiprocessing.Barrier` in order to be consistent with the other synchronization primitives of :mod:`multiprocessing` module. From 862ca69c20e506e6c4f8b8c46c96b9012d812d3f Mon Sep 17 00:00:00 2001 From: Duprat Date: Wed, 6 May 2026 16:14:41 +0200 Subject: [PATCH 5/6] Update news file --- .../Library/2026-05-06-08-44-03.gh-issue-149399.zqSWNs.rst | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Misc/NEWS.d/next/Library/2026-05-06-08-44-03.gh-issue-149399.zqSWNs.rst b/Misc/NEWS.d/next/Library/2026-05-06-08-44-03.gh-issue-149399.zqSWNs.rst index 9a06d295d4471d..65cfb9abeff12a 100644 --- a/Misc/NEWS.d/next/Library/2026-05-06-08-44-03.gh-issue-149399.zqSWNs.rst +++ b/Misc/NEWS.d/next/Library/2026-05-06-08-44-03.gh-issue-149399.zqSWNs.rst @@ -1,4 +1,2 @@ -Change the :meth:`__repr__` of :class:`multiprocessing.Event` -and add a ``__repr__`` method to the :class:`multiprocessing.Barrier` -in order to be consistent with the other synchronization primitives -of :mod:`multiprocessing` module. +Change the ``__repr__`` of :class:`multiprocessing.Event` and add a ``__repr__`` method to the :class:`multiprocessing.Barrier` +in order to be consistent with the other synchronization primitives of :mod:`multiprocessing` module. From bc993ee22a7f9d5ca7f57bd2dda79ba8647d2c12 Mon Sep 17 00:00:00 2001 From: Duprat Date: Thu, 7 May 2026 15:00:02 +0200 Subject: [PATCH 6/6] fix newline format in news --- .../Library/2026-05-06-08-44-03.gh-issue-149399.zqSWNs.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Misc/NEWS.d/next/Library/2026-05-06-08-44-03.gh-issue-149399.zqSWNs.rst b/Misc/NEWS.d/next/Library/2026-05-06-08-44-03.gh-issue-149399.zqSWNs.rst index 65cfb9abeff12a..b462b6b7139f82 100644 --- a/Misc/NEWS.d/next/Library/2026-05-06-08-44-03.gh-issue-149399.zqSWNs.rst +++ b/Misc/NEWS.d/next/Library/2026-05-06-08-44-03.gh-issue-149399.zqSWNs.rst @@ -1,2 +1 @@ -Change the ``__repr__`` of :class:`multiprocessing.Event` and add a ``__repr__`` method to the :class:`multiprocessing.Barrier` -in order to be consistent with the other synchronization primitives of :mod:`multiprocessing` module. +Change the ``__repr__`` of :class:`multiprocessing.Event` and add a ``__repr__`` method to the :class:`multiprocessing.Barrier` in order to be consistent with the other synchronization primitives of :mod:`multiprocessing` module.