Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what does a python process return code -9 mean?

Tags:

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

like image 873
guettli Avatar asked Aug 30 '13 09:08

guettli


People also ask

What is return code in Python?

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.

What is return code in subprocess?

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.

Does Python return exit code?

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.

What is exit code 2 in Python?

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.

What happens when you return a function in Python?

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.

How do you add code after a return statement in Python?

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.

What is the difference between a procedure and a function in Python?

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.

What happens if you don’t include a return statement in Python?

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.


1 Answers

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 
like image 166
guettli Avatar answered Sep 20 '22 16:09

guettli