Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@mvdklip
Copy link
Contributor

@mvdklip mvdklip commented Dec 14, 2016

Unhandled exceptions inside the face and feature detectors cause HTTP connections to hang and 'Future exception was never retrieved' tornado error messages to be logged.

Example problem image:
http://s3-eu-west-1.amazonaws.com/nrcapp/cbf1017e5d2f798d48f5cf07bc428f0b12835e9e

This PR handles the exception by going to the next detector and replaces #812 because I messed that one up.

This problem only seems to occur when USE_GIFSICLE_ENGINE = True and when using the Metadata Endpoint.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 84.522% when pulling c4eefea on nrcmedia:nonetype-has-no-attribute-mode into 031a470 on thumbor:master.

try:
features = self.get_features()
except Exception:
features = None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add logging here? Silencing exceptions isn't great. Also added a metric would be awesome so things can be tracked.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure I could. I'm just not very sure what should be logged/tracked here. The detector is trying to get features within a meta request. To be honest I'm not sure what exactly makes this error. My best guess is that something is not being initialized as a "metadata only" performance optimalization. Any additional thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least the exception message should be logged otherwise this is silently ignoring potential problems with no way of knowing something went wrong.

)
)
except Exception:
self.next(callback)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 84.465% when pulling d42cf56 on nrcmedia:nonetype-has-no-attribute-mode into 031a470 on thumbor:master.

@masom
Copy link
Contributor

masom commented Feb 24, 2017

@mvdklip is this ready to be merged?

@mvdklip
Copy link
Contributor Author

mvdklip commented Feb 28, 2017

@masom Yes as far as I'm concerned. I moved on to a different client, but would be great to have this merged to the base Thumbor.

@masom masom merged commit 28cff9d into thumbor:master Feb 28, 2017
@savar
Copy link
Contributor

savar commented Mar 1, 2017

please see for the "hanging" problem also #808 and #871

@scorphus
Copy link
Member

scorphus commented Mar 4, 2017

Hey, @mvdklip, any hints on how to reproduce the 'NoneType' object has no attribute 'mode' exception? Thanks.

@mvdklip
Copy link
Contributor Author

mvdklip commented Mar 8, 2017

@scorphus As mentioned in the initial comment this exception can be triggered by requesting metadata for a GIF image with USE_GIFSICLE_ENGINE enabled. A link to an example problematic image is provided, but I think it can actually be triggered by any GIF image.

@scorphus
Copy link
Member

scorphus commented Mar 8, 2017

@mvdklip Nice. Would you be willing to write such a test?

@mvdklip
Copy link
Contributor Author

mvdklip commented Mar 8, 2017

@scorphus Willing yes, but to be honest I will probably never do it. I moved on to a different client which means I'm not actively working on Thumbor anymore. Sorry.

@savar
Copy link
Contributor

savar commented Mar 10, 2017

I wonder how this exception can happen in general. Do you have a config file + real request where this error happened?

Because if USE_GIFSICLE_ENGINE = True then the smart_detect() is not really executed

    def smart_detect(self):
        is_gifsicle = (self.context.request.engine.extension == '.gif' and self.context.config.USE_GIFSICLE_ENGINE)
        if (not (self.context.modules.detectors and self.context.request.smart)) or is_gifsicle:
            self.do_image_operations()
            return

the only other place where I find the face_detector to be used is in the filter distributed_collage().. did you use that one?

@mvdklip
Copy link
Contributor Author

mvdklip commented Mar 10, 2017

This URL exhibited the behaviour on both Thumbor 5.x and 6.x:

/unsafe/meta/1000x1000/smart/s3-eu-west-1.amazonaws.com/nrcapp/cbf1017e5d2f798d48f5cf07bc428f0b12835e9e

Also attaching config file:

thumbor.conf.zip

savar added a commit to savar/thumbor that referenced this pull request Mar 11, 2017
the JSONEngine was not having the `extension` attribute stored from the
wrapped Engine which leads to the exception fixed (ignored) in thumbor#841

with the added extension part the transformer won't call smart detection
if gifsicle is enabled and it's a GIF image
savar added a commit to savar/thumbor that referenced this pull request Mar 11, 2017
in thumbor#841 the exception were caugth and ignored and only a small warning
was logged, this will not allow to debug the underlying issue (because
it was actually a fixable issue, see thumbor#883).. so now the exception is
logged as well
@savar
Copy link
Contributor

savar commented Mar 11, 2017

@mvdklip thanks! helped me to find the root cause of your exception

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants