简体   繁体   English

EC2 Python泡菜失败

[英]EC2 python pickle fails

I'm doing a calculation on EC2 using python and when I try to dump a pickle file containing a dictionary, the program just exists, no error notice or anything. 我正在使用python在EC2上进行计算,当我尝试转储包含字典的pickle文件时,该程序就存在了,没有错误通知或任何东西。 The file is large, around 1 gig, but everything works fine on my laptop, just not on EC2. 该文件很大,大约有1 gig,但是在我的笔记本电脑上一切正常,只是在EC2上却不能。 I'm using an m3.large instance with an attached EBS volume with plenty of space. 我正在使用m3.large实例,该实例带有附加的EBS卷,具有足够的空间。 In the following code snippet, it prints out "dumping now" and then.....nothing, no "dumping complete". 在以下代码段中,它打印出“立即转储”,然后.....什么都没有,没有“转储完成”。 No error is caught by 'except'. 'except'不会捕获任何错误。 When I try to load the pickle file I get an EOF Error. 当我尝试加载泡菜文件时,出现EOF错误。

Thanks for any advice! 感谢您的任何建议!

try:
    fp = open(pickleFile,"wb")
    print 'dumping now'
    pickle.dump(dataDict, fp)
    print 'dumping complete'
    fp.close()
except:
    fp = open('/Users/thisUser/Data/report.txt','w')
    fp.write('error writing pickle file')
    fp.close()
  1. Especially if you're debugging file IO, try not to have your debugging depend on said file IO. 特别是在调试文件IO时,请尽量不要使调试依赖于所述文件IO。 If there are any permissions or disk issues, you'll never know since the error message won't be able to write either. 如果有任何权限或磁盘问题,您将永远不会知道,因为错误消息将无法写入。

  2. Try running watch "ls -lh /your/file" , then running your script, to see if the file writing stops suddenly, or is just continuing at a slow pace. 尝试运行watch "ls -lh /your/file" ,然后运行脚本,以查看文件写入是突然停止还是以缓慢的速度继续。

  3. Try Ctrl-C if your script is hung and your watch looks static, and check out where in the traceback your function is spending its time. 如果脚本已挂起并且watch看起来是静态的,请尝试按Ctrl-C组合键,然后查看函数在回溯中花费的时间。

  4. Try pickling elements/keys of the dictionary individually--the pickling may be crashing on an individual complex element. 尝试分别对字典中的元素/键进行酸洗-酸洗可能会在单个复杂元素上崩溃。

  5. Try cPickle 尝试cPickle

  6. Compare your versions at home and on ec2: import cPickle; print cPickle.__version__ 在家里和ec2上比较您的版本: import cPickle; print cPickle.__version__ import cPickle; print cPickle.__version__

  7. Try different pickling versions. 尝试不同的酸洗版本。

I'm not sure which of these might help, but one of them might. 我不确定其中哪一个会有所帮助,但其中之一可能会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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