0

I have a python script and I want to be able to stop it at any time.

If I knew where in the script I may want to stop it I would use quit().

Is there a way to implemet this independent of the current state?

Background: This script runs in a docker container and if I want to stop that container it takes a rather long time to do so and exits with code 137. This bothers me.

Leo L.-J.
  • 21
  • 4
  • [How to stop/terminate a python script from running?](https://stackoverflow.com/q/19782075/3890632) – khelwood Mar 02 '22 at 09:52
  • In order to use sys.exit or something similar i would need to check for the stopcondition at every possible point. – Leo L.-J. Mar 02 '22 at 10:00
  • You can kill the script externally using the `kill` command (depending on your operating system). – khelwood Mar 02 '22 at 11:37

0 Answers0