From 58912084185ac68051c33766ffc787a2ac6e6b52 Mon Sep 17 00:00:00 2001 From: David Stirling Date: Wed, 31 Jul 2024 11:52:07 +0100 Subject: [PATCH 1/2] Set daemon status on keepalive thread --- src/omero/util/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/omero/util/__init__.py b/src/omero/util/__init__.py index be9ff6c9e..85c716d3a 100644 --- a/src/omero/util/__init__.py +++ b/src/omero/util/__init__.py @@ -674,7 +674,7 @@ def run(self): ctx.logger.info("Halted") - self.thread = Task() + self.thread = Task(daemon=True) self.thread.ctx = self self.thread.start() From 0f8fe1cf7fd80f6bdaa7788a5f0b15dcb6d542ec Mon Sep 17 00:00:00 2001 From: Chris Allan Date: Mon, 5 Aug 2024 08:43:15 +0000 Subject: [PATCH 2/2] logging module has handled this condition for some time This code was originally added to address https://trac.openmicroscopy.org/ome/ticket/3260 where an exception was being raised: Traceback (most recent call last): File "/usr/lib/python2.4/logging/__init__.py", line 737, in emit self.stream.write(fs % msg) ValueError: I/O operation on closed file Due to the many changes in interpreter behaviour since Python 2.4, including those surrounding sys.exit in the ~2.6.5 era [^1], as well as improvements to the logging module itself this is no longer an issue. In the referenced Python issue 9501, the related code changes were originally committed in Subversion r84282, Mercurial changeset 42c70f17c2fede6116108568a75b0eec08b3c73a, Git commit 1ddd51fc71c6a6d255eee8e7e54d1bf7e05c5841. Found by tracing the Mercurial changeset via `Misc/svnmap.txt` in the cython repository. At a future date `omero.util.concurrency.AtExitEvent` and `omero.util.concurrency.get_event()` should likely be deprecated and their use discontinued. They attempt to handle issues that no longer exist and add complexity and maintenance overhead to our runtime. See also: * https://bugs.python.org/issue6333 * https://bugs.python.org/issue13807 [^1]: https://stackoverflow.com/questions/3713360/python-2-6-x-theading-signals-atexit-fail-on-some-versions/3765160#3765160 --- src/omero/util/__init__.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/omero/util/__init__.py b/src/omero/util/__init__.py index 85c716d3a..9768979d3 100644 --- a/src/omero/util/__init__.py +++ b/src/omero/util/__init__.py @@ -666,12 +666,6 @@ def run(self): ctx.stop_event.wait(ctx.sleeptime) except ValueError: pass - - if isinstance(ctx.stop_event, - omero.util.concurrency.AtExitEvent): - if ctx.stop_event.atexit: - return # Skipping log. See #3260 - ctx.logger.info("Halted") self.thread = Task(daemon=True)