Skip to content

Commit

Permalink
Drop Windows event loop hack in Python 3.8+ (#573)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cottsay authored Aug 17, 2023
1 parent 52b0078 commit 74a6705
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions colcon_core/executor/sequential.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 74a6705

Please sign in to comment.