Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

asyncio.Runner+PidfdChildWatcher leaves zombie processes #95899

Closed
kumaraditya303 opened this issue Aug 11, 2022 · 2 comments
Closed

asyncio.Runner+PidfdChildWatcher leaves zombie processes #95899

kumaraditya303 opened this issue Aug 11, 2022 · 2 comments
Assignees
Labels
3.11 only security fixes 3.12 bugs and security fixes topic-asyncio type-bug An unexpected behavior, bug, or error

Comments

@kumaraditya303
Copy link
Contributor

import asyncio
import sys
import unittest

import asyncio

asyncio.set_child_watcher(asyncio.PidfdChildWatcher())


def create_free_port():
    return 4  # chosen by a fair dice roll


class TestProc(unittest.IsolatedAsyncioTestCase):
    async def asyncSetUp(self):
        self.port = create_free_port()
        self.proc = await asyncio.create_subprocess_exec(
            sys.executable,
            "-c",  # more realistically this might be an http server or database
            f"import time; print('listening on {self.port}'); import time; time.sleep(2); print('goodbye')",
        )

    async def testProc(self):
        print(f"connecting to {self.port}")

    async def asyncTearDown(self):
        await self.proc.communicate()  # hangs forever on 3.11


if __name__ == "__main__":
    unittest.main()

on python3.10 this produces:

connecting to 4
listening on 4
goodbye
.
----------------------------------------------------------------------
Ran 1 test in 2.022s

OK

on python3.11 it hangs forever in await self.proc.communicate()

Originally posted by @graingert in #95736 (comment)

@graingert
Copy link
Contributor

#94184 would fix this specific combination. I suspect any ChildWatcher that implements attach_loop would be broken

@gvanrossum gvanrossum changed the title asyncio.Runner+PidFdChildWatcher leaves zombie processes asyncio.Runner+PidfdChildWatcher leaves zombie processes Aug 12, 2022
@gvanrossum
Copy link
Member

Why the nonsense with self.port? It does not contribute to understanding the repro but adds useless detail that the reader has to understand before being able to ignore.

miss-islington pushed a commit to miss-islington/cpython that referenced this issue Aug 15, 2022
…ythonGH-95900)

(cherry picked from commit 914f636)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
gvanrossum pushed a commit that referenced this issue Aug 15, 2022
…) (#96003)

(cherry picked from commit 914f636)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.11 only security fixes 3.12 bugs and security fixes topic-asyncio type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants