【问题标题】:Too many open files python打开的文件太多python
【发布时间】:2013-05-27 11:23:13
【问题描述】:

我正在尝试调整图像大小。它工作正常,但我的ImageField,即to_field,正在打开但没有关闭。所以我有一个错误too many open files。我尝试了一些变通解决方案,但无法解决问题。代码如下:

if( to_field.width != size[0] and to_field.height != size[1] ):
   to_field.open()
   image = Image.open(StringIO(to_field.read()))
   old_file_path = to_field.path
   image.resize(size).save(to_field.path)

有什么建议吗??

【问题讨论】:

  • 你/应该image.close()吗? (不熟悉PIL...)
  • 是的,我试过了。没有“关闭”属性
  • How to Close an Image?的可能重复

标签: python django python-imaging-library


【解决方案1】:

老问题,但我认为需要关闭的是 django 字段 to_field

to_field.close()

【讨论】:

    猜你喜欢
    • 2011-05-22
    • 2017-10-09
    • 1970-01-01
    • 1970-01-01
    • 2016-04-21
    • 2013-05-07
    • 2013-05-03
    相关资源
    最近更新 更多