From c8162ad15b40d32696a3e7ec18fb55c3581067b1 Mon Sep 17 00:00:00 2001 From: Scott K Logan Date: Tue, 5 Sep 2023 15:02:50 -0500 Subject: [PATCH] Drop Windows event loop hack in Python 3.8+ In Python versions prior to 3.8, it appears that attempting to close the event loop after a Ctrl-C would reliably hang the process, which would need to be killed. I've been unable to reproduce the behavior in any newer Python versions, so I think it's time to set the timeline for removing the hack entirely. This should take care of the common ResourceWarning messages when using newer Python versions. --- colcon_parallel_executor/executor/parallel.py | 6 ++++-- setup.cfg | 2 -- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/colcon_parallel_executor/executor/parallel.py b/colcon_parallel_executor/executor/parallel.py index be23273..da7c902 100644 --- a/colcon_parallel_executor/executor/parallel.py +++ b/colcon_parallel_executor/executor/parallel.py @@ -96,11 +96,13 @@ def execute(self, args, jobs, *, on_error=OnError.interrupt): # noqa: D102 return 1 finally: # HACK on Windows closing the event loop seems to hang after Ctrl-C - # even though no futures are pending - if sys.platform != 'win32': + # even though no futures are pending, but appears fixed in py3.8 + if sys.platform != 'win32' or sys.version_info >= (3, 8): logger.debug('closing loop') loop.close() logger.debug('loop closed') + else: + logger.debug('skipping loop closure') result = future.result() logger.debug( "run_until_complete finished with '{result}'".format_map(locals())) diff --git a/setup.cfg b/setup.cfg index aa9a326..3517962 100644 --- a/setup.cfg +++ b/setup.cfg @@ -55,8 +55,6 @@ filterwarnings = ignore:pkg_resources is deprecated as an API::flake8_import_order ignore:SelectableGroups dict interface is deprecated::flake8 ignore:Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated::pyreadline - # Suppress resource warnings pending investigation - always::ResourceWarning junit_suite_name = colcon-parallel-executor [options.entry_points]