python-shell icon indicating copy to clipboard operation
python-shell copied to clipboard

Return result from kill()

Open luke-waymark-addinsight opened this issue 4 years ago • 2 comments

Is your feature request related to a problem? Please describe. Using the kill() method has no feedback. The childProcess.kill() method which python-shell uses internally returns a boolean describing the success of the operation, but it's not used. In fact it seems that python-shell assumes it was successfully killed as it sets terminated = true regardless of what happens.

Describe the solution you'd like Return a boolean for success or failure of killing

luke-waymark-addinsight avatar Sep 29 '21 06:09 luke-waymark-addinsight

The kill() method() method already has a return value - it returns this allowing you to chain methods.

Although now that I think about it method chaining in this case is not really useful 🤔. If you kill the process you're probably done calling pythonshell methods.

So feel free to submit a PR changing this behavior if you wish and I'll review it.

Almenon avatar Oct 02 '21 18:10 Almenon

Perhaps rather than setting this.terminated = true blindly, it could instead do this.terminated = this.childProcess.kill(sig), that way you could check the returned object if it successfully terminated and perhaps try again with a more aggressive kill signal.

luke-waymark-addinsight avatar Oct 04 '21 22:10 luke-waymark-addinsight