简体   繁体   中英

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

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])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM