I have a python script which returns the exit status of -9.
I tried to get the root of the problem with the atexit module, but it does not get called.
Any hints to help me find why and where my script terminates?
The problem is reproducible, operating system: linux 3.7.10
The Python return statement is a special statement that you can use inside a function or method to send the function's result back to the caller. A return statement consists of the return keyword followed by an optional return value. The return value of a Python function can be any Python object.
Return Value of the Call() Method from Subprocess in PythonThe Python subprocess call() function returns the executed code of the program. If there is no program output, the function will return the code that it executed successfully. It may also raise a CalledProcessError exception.
0 is the default exit code used by python treated as the successful execution of a program. Any value outside the range of 0-255 is treated as modulo 256.
An error code of 2 is usually (not always) file not found. This to me would suggest that your python script isn't correctly picking up the file. Are you using a relative path in your script? As it may be that when you run it from the cmd line you are in a different location and that is why it works.
As soon as a function hits a return statement, it terminates without executing any subsequent code. Consequently, the code that appears after the function’s return statement is commonly called dead code. The Python interpreter totally ignores dead code when running your functions.
Consider the following function, which adds code after its return statement: >>> def dead_code(): ... return 42 ... # Dead code ... print("Hello, World") ... >>> dead_code() 42 The statement print ("Hello, World") in this example will never execute because that statement appears after the function’s return statement.
Both procedures and functions can act upon a set of input values, commonly known as arguments. In Python, these kinds of named code blocks are known as functions because they always send a value back to the caller. The Python documentation defines a function as follows: A series of statements which returns some value to a caller.
So, if you don’t explicitly use a return value in a return statement, or if you totally omit the return statement, then Python will implicitly return a default value for you. That default return value will always be None. Say you’re writing a function that adds 1 to a number x, but you forget to supply a return statement.
The script was killed by the operating system. Negative return values are the signal number which was used to kill the process.
The script needed too much memory. I found this in syslog:
Out of memory: Kill process 26184 (python) score 439 or sacrifice child Killed process 26184 (python) total-vm:628772kB, anon-rss:447660kB, file-rss:0kB
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With