本文介绍了缩略图标签失败:(sorl-thumbnail 11.12)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在生产环境(使用Sentry作为记录器)中,从sorl-thumbnail中收到奇怪的错误。他们都只是说缩略图标签失败:(这是非常有用的),它们都来自三个模块之一。

I keep getting strange errors from sorl-thumbnail in my production environment (using Sentry as a logger). They all just say Thumbnail tag failed: (which is oh-so-uber-helpful), and they all come from one of three modules.

奇怪的是它并不影响网站。页面加载正常,甚至缩略图加载正常。这真的只是一个问题,因为我厌倦了在我的Sentry仪表板中的列表中看到错误。但是,我不能把头或尾巴摆脱为什么会产生错误,或者如何解决错误。我开始怀疑他们不仅仅是标准行为与过度冗长的日志记录混合,因为就像我所说,网站上没有明显的影响。

The weird thing is that it doesn't actually affect the site. Pages load fine, and even the thumbnails load fine. It's really only a concern because I'm tired of seeing the errors show up in my list in my Sentry dashboard. However, I can't make heads or tails out of why the errors are generated, or how to fix them. I'm starting to wonder if they aren't just standard behavior mixed with overly verbose logging, since like I said, there's no noticeable effect on the site.

也许有人这里可以提供更多的亮点,所以这里是堆栈跟踪。

Perhaps someone here can shed more light on it, so here's the stacktraces.

更新#1

对于 sorl.thumbnail.engines.pil_engine._orientation 中的一个,我发现以下可能的候选人: http://blog.yawd.eu/2012/fix-sorlthumbnail-engines-pil-orientation-error/

For the one from sorl.thumbnail.engines.pil_engine._orientation, I found the following likely candidate: http://blog.yawd.eu/2012/fix-sorlthumbnail-engines-pil-orientation-error/

Thumbnail tag failed:

Stacktrace (most recent call last):

  File "sorl/thumbnail/templatetags/thumbnail.py", line 49, in render
    logger.error('Thumbnail tag failed:', exc_info=sys.exc_info())

  File "sorl/thumbnail/templatetags/thumbnail.py", line 97, in _render
    file_, geometry, **options

  File "sorl/thumbnail/base.py", line 65, in get_thumbnail
    default.kvstore.get_or_set(source)

  File "sorl/thumbnail/kvstores/base.py", line 46, in get_or_set
    cached = self.get(image_file)

  File "sorl/thumbnail/kvstores/base.py", line 25, in get
    return self._get(image_file.key)

  File "sorl/thumbnail/kvstores/base.py", line 127, in _get
    return deserialize_image_file(value)

  File "sorl/thumbnail/images.py", line 31, in deserialize_image_file
    data = simplejson.loads(s)

  File "simplejson/__init__.py", line 428, in loads
    return _default_decoder.decode(s)

  File "simplejson/decoder.py", line 402, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())

  File "simplejson/decoder.py", line 420, in raw_decode
    raise JSONDecodeError("No JSON object could be decoded", s, idx)



sorl.thumbnail.images.read



From sorl.thumbnail.images.read:

Thumbnail tag failed:

Stacktrace (most recent call last):

  File "sorl/thumbnail/templatetags/thumbnail.py", line 49, in render
    logger.error('Thumbnail tag failed:', exc_info=sys.exc_info())

  File "sorl/thumbnail/templatetags/thumbnail.py", line 97, in _render
    file_, geometry, **options

  File "sorl/thumbnail/base.py", line 56, in get_thumbnail
    source_image = default.engine.get_image(source)

  File "sorl/thumbnail/engines/pil_engine.py", line 12, in get_image
    buf = StringIO(source.read())

  File "sorl/thumbnail/images.py", line 121, in read
    return self.storage.open(self.name).read()

  File "django/core/files/storage.py", line 33, in open
    file = self._open(name, mode)

  File "django/core/files/storage.py", line 159, in _open
    return File(open(self.path(name), mode))



From sorl.thumbnail.engines.pil_engine._orientation



From sorl.thumbnail.engines.pil_engine._orientation:

Thumbnail tag failed:

Stacktrace (most recent call last):

  File "sorl/thumbnail/templatetags/thumbnail.py", line 49, in render
    logger.error('Thumbnail tag failed:', exc_info=sys.exc_info())

  File "sorl/thumbnail/templatetags/thumbnail.py", line 97, in _render
    file_, geometry, **options

  File "sorl/thumbnail/base.py", line 61, in get_thumbnail
    thumbnail)

  File "sorl/thumbnail/base.py", line 86, in _create_thumbnail
    image = default.engine.create(source_image, geometry, options)

  File "sorl/thumbnail/engines/base.py", line 15, in create
    image = self.orientation(image, geometry, options)

  File "sorl/thumbnail/engines/base.py", line 26, in orientation
    return self._orientation(image)

  File "sorl/thumbnail/engines/pil_engine.py", line 31, in _orientation
    exif = None

  File "PIL/JpegImagePlugin.py", line 381, in _getexif
    info.load(file)

  File "PIL/TiffImagePlugin.py", line 382, in load
    raise IOError, "not enough data"


推荐答案

我在本地工作时遇到这个问题。运行管理命令后似乎停止了:

I ran into this problem while working locally. It seemed to stop after I ran the management commands:

python manage.py thumbnail clear

后跟

python manage.py thumbnail cleanup

这篇关于缩略图标签失败:(sorl-thumbnail 11.12)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 03:36