我有一个非常简单的Python脚本:不明原因的段错误在Python
import Skype4Py
from random import randint
from time import strftime, sleep
from os import system
interval = 5
def pickStatus():
try:
handler = open("lines.txt", "r")
lines = handler.read().split("\n")
handler.close()
rand = randint(0, len(lines))
line = lines[rand]
print strftime("%Y-%m-%d %I:%M %p [" + str(rand) + "] ") + line
system('notify-send "New status" "' + line + '"')
skype.CurrentUserProfile.MoodText = line
sleep(interval * 60)
pickStatus()
except KeyboardInterrupt:
pass
if __name__ == '__main__':
skype = Skype4Py.Skype()
skype.Attach()
pickStatus()
当我运行它,我有时得到此:
~$ python RandomStatus.py
Segmentation fault
~$
其他时间,不过,剧本运行得很好。我所有的其他Python脚本也能正常工作。这个错误并没有给我足够的上下文,甚至不知道在哪里寻找。有任何想法吗?即使只是获得一些实际的调试信息的方式,将不胜感激。
你确定它是Python的segfaulting,而不是你正在调用的程序'notify-send'吗?你有没有试过把'print'语句放在崩溃的地方? –
当然'系统'导致一个子过程。是不是不可能seg段父母? –
它看起来像是在skype.Attach()后发生。无论从哪里来,我都会把它吐出一次:http://pastebin.com/EHJez3Zm –