From 2008ceada3a0d49dd538b8f645643f56fc236cf6 Mon Sep 17 00:00:00 2001 From: Scott K Logan Date: Wed, 9 Aug 2023 19:22:15 -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_core/executor/sequential.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/colcon_core/executor/sequential.py b/colcon_core/executor/sequential.py index 558e8409..1aab44e7 100644 --- a/colcon_core/executor/sequential.py +++ b/colcon_core/executor/sequential.py @@ -92,9 +92,11 @@ def execute(self, args, jobs, *, on_error=OnError.interrupt): # noqa: D102 if not task.done(): logger.error(f"Task '{task}' not done") # 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') return rc