8

I am facing a problem with a python script getting killed. I had always used this script with no problem at all until two days ago, then it started to print, without any change in the code, the string 'killed' before aborting the execution. Other people have tried to run the same code on their system and it works fine, as it used to do with me until two days ago.

I have read some old similar question, and I have got the problem could be an out-of-memory issue due to a bad memory management in my code. It sounds a little strange to me, since it used to work perfectly until some days ago and the problem appears on my system only.

Do you have any idea on how to inspect the problem and find a possible solution, please?

Python version: Python 2.7.14+

System: Scientific Linux CERN 7

Czaporka
  • 2,190
  • 3
  • 10
  • 23
aleolomorfo
  • 133
  • 1
  • 5
  • 5
    *"Do you have any idea on how to inspect the problem and find a possible solution"* - we will need a lot more information to do that... For starters post the full error. An image of the word `killed` doesn't give any clue as to what is happening. Then, start by posting what OS you use, Python version, and a [mre] of your code – Tomerikoo Jan 28 '21 at 10:19
  • 1
    `killed` is my error message. I do not have an extended error or a traceback, that's everything python prints out, there is nothing else to report. I have all my outputs and then `killed` before the abortion. I do not think a minimal reproducible example of my code could be useful. The code used to work perfectly and without any change it started to kill itself. I think the problem is in the system rather than in the code. – aleolomorfo Jan 28 '21 at 10:35
  • Might be. Please read the question and try to objectively think how someone from the outside can possibly help... At least a screenshot with the actual shell with your Python command and the resulting error would be more helpful than a green "killed" image – Tomerikoo Jan 28 '21 at 10:37
  • 1. Please runn "free -m" on shell and paste its output. 2. Please run pgrep -lf kill on shell and paste its output. 3. Run your script with strace and paste that output also. – lllrnr101 Jan 28 '21 at 10:45
  • Also here: https://stackoverflow.com/questions/19189522/what-does-killed-mean-when-a-processing-of-a-huge-csv-with-python-which-sudde – Jeyekomon Jun 08 '21 at 12:57

1 Answers1

6

In your case, it's highly probale that the script you're processing reached some given limit of the amount of resources it's able to use and that depends on your OS and other parameters, are you running something else with the script ? or are there many open files etc ?

The most likely reason for such an error is exceeding memory use, whiwh forces the system to not take risks and break when allocating more starts failing. Maybe you can print in parallel the total memory you're using to have a glimpse of what's happening since the information you've given are not enough to help you :

import os, psutil
process = psutil.Process(os.getpid())

then: (for python 3)

print(process.memory_info().rss) 

or: (for python 2.7) (tested)

print(process.memory_info()[0])
Younes
  • 391
  • 2
  • 9