Zombie/orphan processes with piped shim executables from entry points, when using editable flag under PowerShell Core
See original GitHub issueEnvironment
- pip version: 20.2.4
- setuptools version: 50.3.2
- Python version: 3.9.0 (tags/v3.9.0:9cf6752, Oct 5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32
- PowerShell Core version: 7.0.3
- OS: Windows 10 Pro 1909 Build: 18363.1139
Description
Some piped shim executables created with pip install --editable . command, seem to hang/morph into zombie/orphan processes under PowerShell Core, when interrupted with Ctrl-C.
This issue doesn’t exist under CMD/Cygwin or if the install is done without the --editable flag. This is why I report the issue here, but it might be a problem with third-party/upstream package or the PowerShell Core machinery itself. Please advise/close if pip is not the source for this issue.
Expected behavior
I expect piped shim executables to exit cleanly/properly upon interruption and not leaving hanging zombie processes.
How to Reproduce
- Setup:
Folder structure:
$ tree
t
├── baz
│ ├── __init__.py
│ ├── foo.py
│ └── bar.py
└── setup.py
Example minimal setup.py file:
from setuptools import setup, find_packages
setup(
name='t',
version='1.0.0',
url='https://example.com',
author='Author Name',
author_email='author@example.com',
description='Description',
packages=find_packages(),
entry_points = {
'console_scripts': ['foo=baz.foo:main', 'bar=baz.bar:main'],
},
install_requires = ['aioconsole>=0.3.1'],
)
Example script foo.py:
from asyncio import run
from asyncio import sleep
from aioconsole.stream import aprint
async def _main():
while True:
await aprint('a')
await sleep(5)
def main():
run(_main())
if __name__ == '__main__':
exit(main())
Example script bar.py:
from asyncio import run
from aioconsole.stream import aprint
from aioconsole.stream import get_standard_streams
async def _main():
reader, _ = await get_standard_streams()
async for line in reader:
await aprint(line)
def main():
run(_main())
if __name__ == '__main__':
exit(main())
Archive with all example files: t.zip
- Create virtualenv and install the package with:
virtualenv venv
. .\venv\Scripts\activate
pip install --editable .
- Run the two shim executables with pipe and interrupt the command after a couple of seconds with
Ctrl+C.
foo | bar
- Check for any zombie/hanging processes - example:

Output Incorrect output under PowerShell Core:
(venv) PS D:\t> foo | bar
b'a\n'
b'a\n'
Traceback (most recent call last):
File "D:\t\venv\Scripts\foo-script.py", line 33, in <module>
sys.exit(load_entry_point('t', 'console_scripts', 'foo')())
File "d:\t\baz\foo.py", line 13, in main
run(_main())
File "C:\Program Files\Python39\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\Program Files\Python39\lib\asyncio\base_events.py", line 629, in run_until_complete
self.run_forever()
File "C:\Program Files\Python39\lib\asyncio\windows_events.py", line 316, in run_forever
super().run_forever()
File "C:\Program Files\Python39\lib\asyncio\base_events.py", line 596, in run_forever
self._run_once()
File "C:\Program Files\Python39\lib\asyncio\base_events.py", line 1854, in _run_once
event_list = self._selector.select(timeout)
File "C:\Program Files\Python39\lib\asyncio\windows_events.py", line 434, in select
self._poll(timeout)
File "C:\Program Files\Python39\lib\asyncio\windows_events.py", line 783, in _poll
status = _overlapped.GetQueuedCompletionStatus(self._iocp, ms)
KeyboardInterrupt
Correct output under CMD (notice the two tracebacks):
(venv) D:\t>foo | bar
b'a\n'
b'a\n'
Traceback (most recent call last):
File "D:\t\venv\Scripts\foo-script.py", line 33, in <module>
sys.exit(load_entry_point('t', 'console_scripts', 'foo')())
File "d:\t\baz\foo.py", line 13, in main
run(_main())
File "C:\Program Files\Python39\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\Program Files\Python39\lib\asyncio\base_events.py", line 629, in run_until_complete
self.run_forever()
File "C:\Program Files\Python39\lib\asyncio\windows_events.py", line 316, in run_forever
super().run_forever()
File "C:\Program Files\Python39\lib\asyncio\base_events.py", line 596, in run_forever
self._run_once()
File "C:\Program Files\Python39\lib\asyncio\base_events.py", line 1854, in _run_once
event_list = self._selector.select(timeout)
File "C:\Program Files\Python39\lib\asyncio\windows_events.py", line 434, in select
self._poll(timeout)
File "C:\Program Files\Python39\lib\asyncio\windows_events.py", line 783, in _poll
status = _overlapped.GetQueuedCompletionStatus(self._iocp, ms)
KeyboardInterrupt
^Traceback (most recent call last):
C File "D:\t\venv\Scripts\bar-script.py", line 33, in <module>
sys.exit(load_entry_point('t', 'console_scripts', 'bar')())
File "d:\t\baz\bar.py", line 14, in main
run(_main())
File "C:\Program Files\Python39\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\Program Files\Python39\lib\asyncio\base_events.py", line 629, in run_until_complete
self.run_forever()
File "C:\Program Files\Python39\lib\asyncio\windows_events.py", line 316, in run_forever
super().run_forever()
File "C:\Program Files\Python39\lib\asyncio\base_events.py", line 596, in run_forever
self._run_once()
File "C:\Program Files\Python39\lib\asyncio\base_events.py", line 1854, in _run_once
event_list = self._selector.select(timeout)
File "C:\Program Files\Python39\lib\asyncio\windows_events.py", line 434, in select
self._poll(timeout)
File "C:\Program Files\Python39\lib\asyncio\windows_events.py", line 783, in _poll
status = _overlapped.GetQueuedCompletionStatus(self._iocp, ms)
KeyboardInterrupt
^C
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)

Top Related StackOverflow Question
Yeah, I’m pretty confident this isn’t a pip issue. Feel free to @-ping me on the setuptools issue if anything I’ve said here needs clarification.
Closing this one for now.