Skip to content

Commit

Permalink
Drop Windows event loop hack in Python 3.8+
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 committed Sep 6, 2023
1 parent 32ef9ac commit c8162ad
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 4 additions & 2 deletions colcon_parallel_executor/executor/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down
2 changes: 0 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit c8162ad

Please sign in to comment.