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
webbrowser creates zombi processes in the background mode #71256
Comments
The webbrowser opens almost all browsers in background mode, it looks like only Elinks is not opened in this mode. Problem: the webbrowser doesn't read the exit status of the browser, and so create zombi process. On Python 3.6, the subprocess module now emits a ResourceWarning in this case (issue bpo-26741). For example, the following script shows a zombi process ("<defunc>"): import webbrowser, os
b = webbrowser.get("firefox")
b.open("https://bugs.python.org/issue26741")
b = None
os.system("ps ax|grep firefox")
input("press ENTER when firefox exited")
os.system("ps ax|grep firefox") I guess that Python should use os.fork() somehow to fix this issue. Another option is to hack the Popen object to not display the warning, but I don't think that it's a safe option. See also the issue bpo-27068 "Add a detach() method to subprocess.Popen", but I don't think that it is directly related to background processes run by webbrowser. |
I checked how "xdg-open http://www.python.org/" works. It looks like the command works as webbrowser: create a child process "firefox URL", but then it waits until the command completes. In fact, "firefox URL" exits quickly. So we can try "background = False" for firefox. Well, at least with my Firefox 46.0.1. |
I think the Firefox command will exit immediately if it just signals an existing Firefox process and window, but becomes the main Firefox process if there isn’t already one running. Background = False sounds like it won’t help. Don’t we want the opposite? |
This appears to be Firefox specific? At least: b = webbrowser.get("chromium-browser")
b.open("https://bugs.python.org/issue26741") returns simply: True With no exception |
Isn't this a duplicate of bpo-5993? |
It does look similar. They probably could be merged. The main difference is in bpo-5993 Eivind suggested to somehow use a “wait” system call, while here Victor suggested “fork” (perhaps to orphan a grandchild process?). |
Python 3.6 was released 5 years ago. Nobody complained about ResourceWarning. While it would be nice to fix the issue, nobody managed to write a fix in 5 years and this issue has no activity for 3 years. I close the issue. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: