-
Notifications
You must be signed in to change notification settings - Fork 857
Description
(Note: I initially reported this here: thumbor-community/aws#57 )
Thumbor request URL
Expected behaviour
Should serve the image smart cropped at 350x50. NOTE: This only happens with /smart enabled when using s3_storage, if I use file storage it works with smart, if I use s3_storage without smart it works (see above linked issue for more details)
Actual behaviour
Operation times out with error messages in the log.
ubuntu@ip-10-0-255-97:~$ thumbor -c /etc/thumbor-config.conf -l debug
libdc1394 error: Failed to initialize libdc1394
2016-05-10 00:19:59 root:DEBUG thumbor running at 0.0.0.0:8888
2016-05-10 00:20:06 thumbor:DEBUG Cleaning key: gfr/source-assets/img/2016/05/09/9524d1f3-027e-4335-97c1-b12bc462780f.jpg
2016-05-10 00:20:06 thumbor:DEBUG Cleansed key: gfr/source-assets/img/2016/05/09/9524d1f3-027e-4335-97c1-b12bc462780f.jpg
2016-05-10 00:20:06 thumbor:DEBUG Cleaning key: gfr/source-assets/img/2016/05/09/9524d1f3-027e-4335-97c1-b12bc462780f.jpg
2016-05-10 00:20:06 thumbor:DEBUG Cleansed key: gfr/source-assets/img/2016/05/09/9524d1f3-027e-4335-97c1-b12bc462780f.jpg
2016-05-10 00:20:06 thumbor:DEBUG METRICS: inc: storage.hit:1
2016-05-10 00:20:06 thumbor:DEBUG Cleaning key: gfr/source-assets/img/2016/05/09/9524d1f3-027e-4335-97c1-b12bc462780f.detectors.txt
2016-05-10 00:20:06 thumbor:DEBUG Cleansed key: gfr/source-assets/img/2016/05/09/9524d1f3-027e-4335-97c1-b12bc462780f.detectors.txt
2016-05-10 00:31:41 botocore.utils:DEBUG URI updated to: https://<bucketpath>/img/2016/05/09/9524d1f3-027e-4335-97c1-b12bc462780f.detectors.txt
2016-05-10 00:31:41 botocore.auth:DEBUG Calculating signature using hmacv1 auth.
2016-05-10 00:31:41 botocore.auth:DEBUG HTTP request method: GET
2016-05-10 00:20:06 tornado.application:ERROR Future exception was never retrieved: Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/tornado/gen.py", line 1017, in run
yielded = self.gen.send(value)
File "/usr/local/lib/python2.7/dist-packages/thumbor/handlers/__init__.py", line 177, in get_image
self.filters_runner.apply_filters(thumbor.filters.PHASE_AFTER_LOAD, transform)
File "/usr/local/lib/python2.7/dist-packages/thumbor/filters/__init__.py", line 81, in apply_filters
callback()
File "/usr/local/lib/python2.7/dist-packages/thumbor/handlers/__init__.py", line 175, in transform
self.context.transformer.transform(after_transform_cb)
File "/usr/local/lib/python2.7/dist-packages/thumbor/transformer.py", line 102, in transform
self.smart_detect()
File "/usr/local/lib/python2.7/dist-packages/thumbor/transformer.py", line 151, in smart_detect
self.do_smart_detection().result()
File "/usr/local/lib/python2.7/dist-packages/tornado/concurrent.py", line 233, in result
self._check_done()
File "/usr/local/lib/python2.7/dist-packages/tornado/concurrent.py", line 311, in _check_done
raise Exception("DummyFuture does not support blocking for results")
Exception: DummyFuture does not support blocking for results
2016-05-10 00:30:46 botocore.parsers:DEBUG Response headers: <tornado.httputil.HTTPHeaders object at 0x7fc4c9a11050>
2016-05-10 00:30:46 botocore.parsers:DEBUG Response body:
<botocore.response.StreamingBody object at 0x7fc4c9c72110>
I removed all lines with botocore (except those last few which are somewhat interesting in that they happen around the exception) or x-amz-security on them, but there were no errors from botocore, it was properly getting the files and putting them ( I can see the results on the bucket itself).
Operating system
$ uname -a
Linux ip-10-0-255-97 3.13.0-74-generic #118-Ubuntu SMP Thu Dec 17 22:52:10 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.4 LTS"
Your thumbor.conf
ALLOWED_SOURCES = [ '.*\.?domains\.net', '.*\.?asd\.com', '.*\.?asdsada\.com',
'.*\.?fdfef\.com'
]
IGNORE_SMART_ERRORS = False
LOADER = 'tc_aws.loaders.s3_loader'
STORAGE = 'tc_aws.storages.s3_storage'
RESULT_STORAGE='tc_redis.result_storages.redis_result_storage'
MAX_ID_LENGTH = 128
TC_AWS_REGION='us-east-1'
TC_AWS_STORAGE_BUCKET='real bucket name I swear!' # S3 bucket for Storage
TC_AWS_STORAGE_ROOT_PATH='gfr/' # S3 path prefix for Storage bucket
TC_AWS_STORAGE_RRS=True
TC_AWS_ENABLE_HTTP_LOADER=True
TC_AWS_ALLOWED_BUCKETS=['real bucket names I swear!']
DETECTORS = [
'thumbor.detectors.face_detector',
'thumbor.detectors.glasses_detector',
'thumbor.detectors.feature_detector',
'thumbor.detectors.profile_detector'
]
OPTIMIZERS = [ 'thumbor.optimizers.jpegtran' ]
JPEGTRAN_PATH = '/usr/bin/jpegtran'
FFMPEG_PATH = '/usr/bin/avconv'
RESULT_STORAGE_EXPIRATION_SECONDS = 0
REDIS_RESULT_STORAGE_SERVER_HOST = '<redis host>'
REDIS_RESULT_STORAGE_SERVER_PORT = 6379
REDIS_RESULT_STORAGE_SERVER_DB = 0
REDIS_RESULT_STORAGE_SERVER_PASSWORD = None
REDIS_QUEUE_SERVER_HOST = '<redis host>'
I believe I have fixed the issue with the following simple changes (I will PR soon), but I am unaware of any side effect it might have as tornado is entirely new to me:
diff --git a/thumbor/transformer.py b/thumbor/transformer.py
index 5b381df..b301964 100644
--- a/thumbor/transformer.py
+++ b/thumbor/transformer.py
@@ -131,6 +131,7 @@ class Transformer(object):
def smart_storage_key(self):
return self.context.request.image_url
+ @gen.coroutine
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:
@@ -148,7 +149,7 @@ class Transformer(object):
# image operation inside the try block.
self.should_run_image_operations = False
self.running_smart_detection = True
- self.do_smart_detection().result()
+ yield self.do_smart_detection()
self.running_smart_detection = False
except Exception:
if not self.context.config.IGNORE_SMART_ERRORS:
Thanks.