Why do I get subprocess resource warnings despite the process being dead?How to terminate a python subprocess launched with shell=TrueHow can I handle SIGCHLD?How can I prevent zombie child processes?Ensuring subprocesses are dead on exiting Python programWhat killed my process and why?python subprocess with shell=True: redirections and platform-independent subprocess killingConstantly print Subprocess output while process is runningHow to embed compilable python code onto ConfluenceHow to run in python subprocess without blocking parent process?Close Image with subprocessFFMPEG not save logs when converting to audio formatpython subprocess.popen kill subprog when parent prog exits?Bizarre hang in python when subprocess returns an error
Why doesn't using multiple commands with a || or && conditional work?
Why can't we play rap on piano?
Why is it a bad idea to hire a hitman to eliminate most corrupt politicians?
Does the Idaho Potato Commission associate potato skins with healthy eating?
Bullying boss launched a smear campaign and made me unemployable
Plagiarism or not?
If human space travel is limited by the G force vulnerability, is there a way to counter G forces?
Can the Meissner effect explain very large floating structures?
What method can I use to design a dungeon difficult enough that the PCs can't make it through without killing them?
Should I tell management that I intend to leave due to bad software development practices?
How to tell a function to use the default argument values?
What is the most common color to indicate the input-field is disabled?
How could indestructible materials be used in power generation?
Mathematica command that allows it to read my intentions
What mechanic is there to disable a threat instead of killing it?
How much of data wrangling is a data scientist's job?
Why was the shrinking from 8″ made only to 5.25″ and not smaller (4″ or less)?
Valid term from quadratic sequence?
How would I stat a creature to be immune to everything but the Magic Missile spell? (just for fun)
Can my sorcerer use a spellbook only to collect spells and scribe scrolls, not cast?
Should I cover my bicycle overnight while bikepacking?
What do you call someone who asks many questions?
Is it logically or scientifically possible to artificially send energy to the body?
Why would the Red Woman birth a shadow if she worshipped the Lord of the Light?
Why do I get subprocess resource warnings despite the process being dead?
How to terminate a python subprocess launched with shell=TrueHow can I handle SIGCHLD?How can I prevent zombie child processes?Ensuring subprocesses are dead on exiting Python programWhat killed my process and why?python subprocess with shell=True: redirections and platform-independent subprocess killingConstantly print Subprocess output while process is runningHow to embed compilable python code onto ConfluenceHow to run in python subprocess without blocking parent process?Close Image with subprocessFFMPEG not save logs when converting to audio formatpython subprocess.popen kill subprog when parent prog exits?Bizarre hang in python when subprocess returns an error
I've been trying to figure out how to spin up different subprocess instances and then killing them and then creating new ones. The parent python process never does, it just kills the subprocesses. I followed a lot of links on SO but I keep getting the following message once the parent python process ends:
F/Users/Lucifer/miniconda3/envs/rltp/lib/python3.6/subprocess.py:761: ResourceWarning: subprocess 40909 is still running ResourceWarning, source=self)
it seems interesting because I did ps but I get nothing:
PID TTY TIME CMD
7070 ttys001 0:00.06 /Applications/iTerm.app/Contents/MacOS/iTerm2 --server login -fp Lucifer
7072 ttys001 0:00.61 -bash
17723 ttys002 0:00.06 /Applications/iTerm.app/Contents/MacOS/iTerm2 --server login -fp Lucifer
17725 ttys002 0:00.06 -bash
38586 ttys002 0:00.16 sertop --no_init
I simply want to start a process:
self.serapi = subprocess.Popen(['sertop','--no_init'],
stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE,
preexec_fn=os.setsid,shell=True
,)
and kill it:
os.killpg(os.getpgid(self.serapi.pid), signal.SIGTERM)
the above code is essentially copied from the top answer:
How to terminate a python subprocess launched with shell=True
but I am unsure why I get this message. Am I killing the child process successfully? I plan to start and kill many of them.
Note I don't know or need shell=True. I just copied that cuz thats how the answer/question I posted has it. I'd prefer to not have that parameter.
according to the answer I tried:
def kill(self):
self.serapi.wait()
#self.serapi.kill()
self.serapi.terminate()
#os.killpg(os.getpgid(self.serapi.pid), signal.SIGTERM)
#self.serapi.wait()
and different permutations of the above but nothing really seemed to work. Any advice?
python subprocess kill kill-process
add a comment |
I've been trying to figure out how to spin up different subprocess instances and then killing them and then creating new ones. The parent python process never does, it just kills the subprocesses. I followed a lot of links on SO but I keep getting the following message once the parent python process ends:
F/Users/Lucifer/miniconda3/envs/rltp/lib/python3.6/subprocess.py:761: ResourceWarning: subprocess 40909 is still running ResourceWarning, source=self)
it seems interesting because I did ps but I get nothing:
PID TTY TIME CMD
7070 ttys001 0:00.06 /Applications/iTerm.app/Contents/MacOS/iTerm2 --server login -fp Lucifer
7072 ttys001 0:00.61 -bash
17723 ttys002 0:00.06 /Applications/iTerm.app/Contents/MacOS/iTerm2 --server login -fp Lucifer
17725 ttys002 0:00.06 -bash
38586 ttys002 0:00.16 sertop --no_init
I simply want to start a process:
self.serapi = subprocess.Popen(['sertop','--no_init'],
stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE,
preexec_fn=os.setsid,shell=True
,)
and kill it:
os.killpg(os.getpgid(self.serapi.pid), signal.SIGTERM)
the above code is essentially copied from the top answer:
How to terminate a python subprocess launched with shell=True
but I am unsure why I get this message. Am I killing the child process successfully? I plan to start and kill many of them.
Note I don't know or need shell=True. I just copied that cuz thats how the answer/question I posted has it. I'd prefer to not have that parameter.
according to the answer I tried:
def kill(self):
self.serapi.wait()
#self.serapi.kill()
self.serapi.terminate()
#os.killpg(os.getpgid(self.serapi.pid), signal.SIGTERM)
#self.serapi.wait()
and different permutations of the above but nothing really seemed to work. Any advice?
python subprocess kill kill-process
Did youwait()on the subprocess? Even after a child process exits, it remains a zombie until its parent callswait()and retrieves its exit status.
– Daniel Pryden
Mar 7 at 20:15
@DanielPryden I did not callwait()I did not know that call existed until you mentioned it.
– Charlie Parker
Mar 7 at 22:01
Great! I figured as much, which is why I wrote the answer below. If you found it useful, please feel free to upvote and/or accept it. Glad I could help!
– Daniel Pryden
Mar 7 at 22:01
@DanielPryden looking at the docks callingwait()seems to deadlock if both arestdout,stderr = PIPE, besides my process never ends until I tell it to end.
– Charlie Parker
Mar 7 at 22:02
add a comment |
I've been trying to figure out how to spin up different subprocess instances and then killing them and then creating new ones. The parent python process never does, it just kills the subprocesses. I followed a lot of links on SO but I keep getting the following message once the parent python process ends:
F/Users/Lucifer/miniconda3/envs/rltp/lib/python3.6/subprocess.py:761: ResourceWarning: subprocess 40909 is still running ResourceWarning, source=self)
it seems interesting because I did ps but I get nothing:
PID TTY TIME CMD
7070 ttys001 0:00.06 /Applications/iTerm.app/Contents/MacOS/iTerm2 --server login -fp Lucifer
7072 ttys001 0:00.61 -bash
17723 ttys002 0:00.06 /Applications/iTerm.app/Contents/MacOS/iTerm2 --server login -fp Lucifer
17725 ttys002 0:00.06 -bash
38586 ttys002 0:00.16 sertop --no_init
I simply want to start a process:
self.serapi = subprocess.Popen(['sertop','--no_init'],
stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE,
preexec_fn=os.setsid,shell=True
,)
and kill it:
os.killpg(os.getpgid(self.serapi.pid), signal.SIGTERM)
the above code is essentially copied from the top answer:
How to terminate a python subprocess launched with shell=True
but I am unsure why I get this message. Am I killing the child process successfully? I plan to start and kill many of them.
Note I don't know or need shell=True. I just copied that cuz thats how the answer/question I posted has it. I'd prefer to not have that parameter.
according to the answer I tried:
def kill(self):
self.serapi.wait()
#self.serapi.kill()
self.serapi.terminate()
#os.killpg(os.getpgid(self.serapi.pid), signal.SIGTERM)
#self.serapi.wait()
and different permutations of the above but nothing really seemed to work. Any advice?
python subprocess kill kill-process
I've been trying to figure out how to spin up different subprocess instances and then killing them and then creating new ones. The parent python process never does, it just kills the subprocesses. I followed a lot of links on SO but I keep getting the following message once the parent python process ends:
F/Users/Lucifer/miniconda3/envs/rltp/lib/python3.6/subprocess.py:761: ResourceWarning: subprocess 40909 is still running ResourceWarning, source=self)
it seems interesting because I did ps but I get nothing:
PID TTY TIME CMD
7070 ttys001 0:00.06 /Applications/iTerm.app/Contents/MacOS/iTerm2 --server login -fp Lucifer
7072 ttys001 0:00.61 -bash
17723 ttys002 0:00.06 /Applications/iTerm.app/Contents/MacOS/iTerm2 --server login -fp Lucifer
17725 ttys002 0:00.06 -bash
38586 ttys002 0:00.16 sertop --no_init
I simply want to start a process:
self.serapi = subprocess.Popen(['sertop','--no_init'],
stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE,
preexec_fn=os.setsid,shell=True
,)
and kill it:
os.killpg(os.getpgid(self.serapi.pid), signal.SIGTERM)
the above code is essentially copied from the top answer:
How to terminate a python subprocess launched with shell=True
but I am unsure why I get this message. Am I killing the child process successfully? I plan to start and kill many of them.
Note I don't know or need shell=True. I just copied that cuz thats how the answer/question I posted has it. I'd prefer to not have that parameter.
according to the answer I tried:
def kill(self):
self.serapi.wait()
#self.serapi.kill()
self.serapi.terminate()
#os.killpg(os.getpgid(self.serapi.pid), signal.SIGTERM)
#self.serapi.wait()
and different permutations of the above but nothing really seemed to work. Any advice?
python subprocess kill kill-process
python subprocess kill kill-process
edited Mar 7 at 22:18
Charlie Parker
asked Mar 7 at 20:10
Charlie ParkerCharlie Parker
1,71543659
1,71543659
Did youwait()on the subprocess? Even after a child process exits, it remains a zombie until its parent callswait()and retrieves its exit status.
– Daniel Pryden
Mar 7 at 20:15
@DanielPryden I did not callwait()I did not know that call existed until you mentioned it.
– Charlie Parker
Mar 7 at 22:01
Great! I figured as much, which is why I wrote the answer below. If you found it useful, please feel free to upvote and/or accept it. Glad I could help!
– Daniel Pryden
Mar 7 at 22:01
@DanielPryden looking at the docks callingwait()seems to deadlock if both arestdout,stderr = PIPE, besides my process never ends until I tell it to end.
– Charlie Parker
Mar 7 at 22:02
add a comment |
Did youwait()on the subprocess? Even after a child process exits, it remains a zombie until its parent callswait()and retrieves its exit status.
– Daniel Pryden
Mar 7 at 20:15
@DanielPryden I did not callwait()I did not know that call existed until you mentioned it.
– Charlie Parker
Mar 7 at 22:01
Great! I figured as much, which is why I wrote the answer below. If you found it useful, please feel free to upvote and/or accept it. Glad I could help!
– Daniel Pryden
Mar 7 at 22:01
@DanielPryden looking at the docks callingwait()seems to deadlock if both arestdout,stderr = PIPE, besides my process never ends until I tell it to end.
– Charlie Parker
Mar 7 at 22:02
Did you
wait() on the subprocess? Even after a child process exits, it remains a zombie until its parent calls wait() and retrieves its exit status.– Daniel Pryden
Mar 7 at 20:15
Did you
wait() on the subprocess? Even after a child process exits, it remains a zombie until its parent calls wait() and retrieves its exit status.– Daniel Pryden
Mar 7 at 20:15
@DanielPryden I did not call
wait() I did not know that call existed until you mentioned it.– Charlie Parker
Mar 7 at 22:01
@DanielPryden I did not call
wait() I did not know that call existed until you mentioned it.– Charlie Parker
Mar 7 at 22:01
Great! I figured as much, which is why I wrote the answer below. If you found it useful, please feel free to upvote and/or accept it. Glad I could help!
– Daniel Pryden
Mar 7 at 22:01
Great! I figured as much, which is why I wrote the answer below. If you found it useful, please feel free to upvote and/or accept it. Glad I could help!
– Daniel Pryden
Mar 7 at 22:01
@DanielPryden looking at the docks calling
wait() seems to deadlock if both are stdout,stderr = PIPE, besides my process never ends until I tell it to end.– Charlie Parker
Mar 7 at 22:02
@DanielPryden looking at the docks calling
wait() seems to deadlock if both are stdout,stderr = PIPE, besides my process never ends until I tell it to end.– Charlie Parker
Mar 7 at 22:02
add a comment |
1 Answer
1
active
oldest
votes
The ResourceWarning: subprocess N is still running warning comes from the __del__ method of the subprocess.Popen class.
If you look at the source for that method, you'll see this comment:
# Not reading subprocess exit status creates a zombie process which
# is only destroyed at the parent python process exit
_warn("subprocess %s is still running" % self.pid,
ResourceWarning, source=self)
The solution is to ensure you call wait() on the child process.
See the NOTES section of the man page for wait(2) for more background information.
In Python, the easiest way to handle this situation is to keep track of all the Popen objects you have created, and ensure that something calls wait() on them, either directly or indirectly.
Alternatively, you can install a SIGCHLD handler that ignores SIGCHLD events; then your child processes will disappear immediately, but you will now be unable to call wait() on them. See also How can I prevent zombie child processes? and How can I handle SIGCHLD?
I tried different variations of the followingself.serapi.wait();#self.serapi.kill();#self.serapi.terminate();but it didn't work. So I guess callingwait()and then terminating/killing the process doesn't work? Or am I missing something?
– Charlie Parker
Mar 7 at 22:07
but is the process still running? I don't understand what is going on because when I do apsI don't see it... :/
– Charlie Parker
Mar 7 at 22:15
1
You should kill the process first, and then wait on it. At the kernel level,waitdoesn't literally mean "wait", it means "receive postmortem information". The process may in fact not be a zombie, depending on how you fork it. But thePopenclass thinks the subprocess must still be running (or must be a zombie), because you haven't received any postmortem information yet. Does that make sense?
– Daniel Pryden
Mar 8 at 3:08
Ok so I callwait(really badly named name for what its suppose to be for) afterkill. How do I know if everything was successful? I am sure I tried this but it wasn't clear if it worked. What I am trying to do is running a new subprocess for each of my unit tests. I'd like to create a new subprocess.
– Charlie Parker
Mar 11 at 0:24
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55052055%2fwhy-do-i-get-subprocess-resource-warnings-despite-the-process-being-dead%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The ResourceWarning: subprocess N is still running warning comes from the __del__ method of the subprocess.Popen class.
If you look at the source for that method, you'll see this comment:
# Not reading subprocess exit status creates a zombie process which
# is only destroyed at the parent python process exit
_warn("subprocess %s is still running" % self.pid,
ResourceWarning, source=self)
The solution is to ensure you call wait() on the child process.
See the NOTES section of the man page for wait(2) for more background information.
In Python, the easiest way to handle this situation is to keep track of all the Popen objects you have created, and ensure that something calls wait() on them, either directly or indirectly.
Alternatively, you can install a SIGCHLD handler that ignores SIGCHLD events; then your child processes will disappear immediately, but you will now be unable to call wait() on them. See also How can I prevent zombie child processes? and How can I handle SIGCHLD?
I tried different variations of the followingself.serapi.wait();#self.serapi.kill();#self.serapi.terminate();but it didn't work. So I guess callingwait()and then terminating/killing the process doesn't work? Or am I missing something?
– Charlie Parker
Mar 7 at 22:07
but is the process still running? I don't understand what is going on because when I do apsI don't see it... :/
– Charlie Parker
Mar 7 at 22:15
1
You should kill the process first, and then wait on it. At the kernel level,waitdoesn't literally mean "wait", it means "receive postmortem information". The process may in fact not be a zombie, depending on how you fork it. But thePopenclass thinks the subprocess must still be running (or must be a zombie), because you haven't received any postmortem information yet. Does that make sense?
– Daniel Pryden
Mar 8 at 3:08
Ok so I callwait(really badly named name for what its suppose to be for) afterkill. How do I know if everything was successful? I am sure I tried this but it wasn't clear if it worked. What I am trying to do is running a new subprocess for each of my unit tests. I'd like to create a new subprocess.
– Charlie Parker
Mar 11 at 0:24
add a comment |
The ResourceWarning: subprocess N is still running warning comes from the __del__ method of the subprocess.Popen class.
If you look at the source for that method, you'll see this comment:
# Not reading subprocess exit status creates a zombie process which
# is only destroyed at the parent python process exit
_warn("subprocess %s is still running" % self.pid,
ResourceWarning, source=self)
The solution is to ensure you call wait() on the child process.
See the NOTES section of the man page for wait(2) for more background information.
In Python, the easiest way to handle this situation is to keep track of all the Popen objects you have created, and ensure that something calls wait() on them, either directly or indirectly.
Alternatively, you can install a SIGCHLD handler that ignores SIGCHLD events; then your child processes will disappear immediately, but you will now be unable to call wait() on them. See also How can I prevent zombie child processes? and How can I handle SIGCHLD?
I tried different variations of the followingself.serapi.wait();#self.serapi.kill();#self.serapi.terminate();but it didn't work. So I guess callingwait()and then terminating/killing the process doesn't work? Or am I missing something?
– Charlie Parker
Mar 7 at 22:07
but is the process still running? I don't understand what is going on because when I do apsI don't see it... :/
– Charlie Parker
Mar 7 at 22:15
1
You should kill the process first, and then wait on it. At the kernel level,waitdoesn't literally mean "wait", it means "receive postmortem information". The process may in fact not be a zombie, depending on how you fork it. But thePopenclass thinks the subprocess must still be running (or must be a zombie), because you haven't received any postmortem information yet. Does that make sense?
– Daniel Pryden
Mar 8 at 3:08
Ok so I callwait(really badly named name for what its suppose to be for) afterkill. How do I know if everything was successful? I am sure I tried this but it wasn't clear if it worked. What I am trying to do is running a new subprocess for each of my unit tests. I'd like to create a new subprocess.
– Charlie Parker
Mar 11 at 0:24
add a comment |
The ResourceWarning: subprocess N is still running warning comes from the __del__ method of the subprocess.Popen class.
If you look at the source for that method, you'll see this comment:
# Not reading subprocess exit status creates a zombie process which
# is only destroyed at the parent python process exit
_warn("subprocess %s is still running" % self.pid,
ResourceWarning, source=self)
The solution is to ensure you call wait() on the child process.
See the NOTES section of the man page for wait(2) for more background information.
In Python, the easiest way to handle this situation is to keep track of all the Popen objects you have created, and ensure that something calls wait() on them, either directly or indirectly.
Alternatively, you can install a SIGCHLD handler that ignores SIGCHLD events; then your child processes will disappear immediately, but you will now be unable to call wait() on them. See also How can I prevent zombie child processes? and How can I handle SIGCHLD?
The ResourceWarning: subprocess N is still running warning comes from the __del__ method of the subprocess.Popen class.
If you look at the source for that method, you'll see this comment:
# Not reading subprocess exit status creates a zombie process which
# is only destroyed at the parent python process exit
_warn("subprocess %s is still running" % self.pid,
ResourceWarning, source=self)
The solution is to ensure you call wait() on the child process.
See the NOTES section of the man page for wait(2) for more background information.
In Python, the easiest way to handle this situation is to keep track of all the Popen objects you have created, and ensure that something calls wait() on them, either directly or indirectly.
Alternatively, you can install a SIGCHLD handler that ignores SIGCHLD events; then your child processes will disappear immediately, but you will now be unable to call wait() on them. See also How can I prevent zombie child processes? and How can I handle SIGCHLD?
edited Mar 7 at 20:29
answered Mar 7 at 20:23
Daniel PrydenDaniel Pryden
47.2k975117
47.2k975117
I tried different variations of the followingself.serapi.wait();#self.serapi.kill();#self.serapi.terminate();but it didn't work. So I guess callingwait()and then terminating/killing the process doesn't work? Or am I missing something?
– Charlie Parker
Mar 7 at 22:07
but is the process still running? I don't understand what is going on because when I do apsI don't see it... :/
– Charlie Parker
Mar 7 at 22:15
1
You should kill the process first, and then wait on it. At the kernel level,waitdoesn't literally mean "wait", it means "receive postmortem information". The process may in fact not be a zombie, depending on how you fork it. But thePopenclass thinks the subprocess must still be running (or must be a zombie), because you haven't received any postmortem information yet. Does that make sense?
– Daniel Pryden
Mar 8 at 3:08
Ok so I callwait(really badly named name for what its suppose to be for) afterkill. How do I know if everything was successful? I am sure I tried this but it wasn't clear if it worked. What I am trying to do is running a new subprocess for each of my unit tests. I'd like to create a new subprocess.
– Charlie Parker
Mar 11 at 0:24
add a comment |
I tried different variations of the followingself.serapi.wait();#self.serapi.kill();#self.serapi.terminate();but it didn't work. So I guess callingwait()and then terminating/killing the process doesn't work? Or am I missing something?
– Charlie Parker
Mar 7 at 22:07
but is the process still running? I don't understand what is going on because when I do apsI don't see it... :/
– Charlie Parker
Mar 7 at 22:15
1
You should kill the process first, and then wait on it. At the kernel level,waitdoesn't literally mean "wait", it means "receive postmortem information". The process may in fact not be a zombie, depending on how you fork it. But thePopenclass thinks the subprocess must still be running (or must be a zombie), because you haven't received any postmortem information yet. Does that make sense?
– Daniel Pryden
Mar 8 at 3:08
Ok so I callwait(really badly named name for what its suppose to be for) afterkill. How do I know if everything was successful? I am sure I tried this but it wasn't clear if it worked. What I am trying to do is running a new subprocess for each of my unit tests. I'd like to create a new subprocess.
– Charlie Parker
Mar 11 at 0:24
I tried different variations of the following
self.serapi.wait();#self.serapi.kill();#self.serapi.terminate(); but it didn't work. So I guess calling wait() and then terminating/killing the process doesn't work? Or am I missing something?– Charlie Parker
Mar 7 at 22:07
I tried different variations of the following
self.serapi.wait();#self.serapi.kill();#self.serapi.terminate(); but it didn't work. So I guess calling wait() and then terminating/killing the process doesn't work? Or am I missing something?– Charlie Parker
Mar 7 at 22:07
but is the process still running? I don't understand what is going on because when I do a
ps I don't see it... :/– Charlie Parker
Mar 7 at 22:15
but is the process still running? I don't understand what is going on because when I do a
ps I don't see it... :/– Charlie Parker
Mar 7 at 22:15
1
1
You should kill the process first, and then wait on it. At the kernel level,
wait doesn't literally mean "wait", it means "receive postmortem information". The process may in fact not be a zombie, depending on how you fork it. But the Popen class thinks the subprocess must still be running (or must be a zombie), because you haven't received any postmortem information yet. Does that make sense?– Daniel Pryden
Mar 8 at 3:08
You should kill the process first, and then wait on it. At the kernel level,
wait doesn't literally mean "wait", it means "receive postmortem information". The process may in fact not be a zombie, depending on how you fork it. But the Popen class thinks the subprocess must still be running (or must be a zombie), because you haven't received any postmortem information yet. Does that make sense?– Daniel Pryden
Mar 8 at 3:08
Ok so I call
wait (really badly named name for what its suppose to be for) after kill. How do I know if everything was successful? I am sure I tried this but it wasn't clear if it worked. What I am trying to do is running a new subprocess for each of my unit tests. I'd like to create a new subprocess.– Charlie Parker
Mar 11 at 0:24
Ok so I call
wait (really badly named name for what its suppose to be for) after kill. How do I know if everything was successful? I am sure I tried this but it wasn't clear if it worked. What I am trying to do is running a new subprocess for each of my unit tests. I'd like to create a new subprocess.– Charlie Parker
Mar 11 at 0:24
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55052055%2fwhy-do-i-get-subprocess-resource-warnings-despite-the-process-being-dead%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Did you
wait()on the subprocess? Even after a child process exits, it remains a zombie until its parent callswait()and retrieves its exit status.– Daniel Pryden
Mar 7 at 20:15
@DanielPryden I did not call
wait()I did not know that call existed until you mentioned it.– Charlie Parker
Mar 7 at 22:01
Great! I figured as much, which is why I wrote the answer below. If you found it useful, please feel free to upvote and/or accept it. Glad I could help!
– Daniel Pryden
Mar 7 at 22:01
@DanielPryden looking at the docks calling
wait()seems to deadlock if both arestdout,stderr = PIPE, besides my process never ends until I tell it to end.– Charlie Parker
Mar 7 at 22:02