Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python script gets "killed"

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

like image 453
aleolomorfo Avatar asked May 23 '26 16:05

aleolomorfo


1 Answers

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])
like image 104
Younes Avatar answered May 26 '26 04:05

Younes



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!