From e6db255c53ec5b3923848a8b6fb530c1245c8005 Mon Sep 17 00:00:00 2001 From: Paul Annesley Date: Mon, 17 Nov 2014 17:41:26 -0800 Subject: [PATCH 1/2] setup.py requires botornado --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 9d8ebb9..a50f1a6 100644 --- a/setup.py +++ b/setup.py @@ -11,5 +11,5 @@ zip_safe = False, include_package_data = True, packages=find_packages(), - requires=['dateutil','thumbor','boto'] -) \ No newline at end of file + requires=['dateutil','thumbor','boto','botornado'] +) From 1b464f3d6d87797e5f2a63154ca1cb1f497b2307 Mon Sep 17 00:00:00 2001 From: Paul Annesley Date: Mon, 17 Nov 2014 17:40:31 -0800 Subject: [PATCH 2/2] s3_loader uses async botornado for S3 access. --- thumbor_aws/loaders/s3_loader.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/thumbor_aws/loaders/s3_loader.py b/thumbor_aws/loaders/s3_loader.py index 8b17abd..bdda8f4 100644 --- a/thumbor_aws/loaders/s3_loader.py +++ b/thumbor_aws/loaders/s3_loader.py @@ -1,7 +1,7 @@ # coding: utf-8 -from boto.s3.connection import S3Connection -from boto.s3.bucket import Bucket +from botornado.s3.connection import AsyncS3Connection +from botornado.s3.bucket import AsyncBucket from boto.s3.key import Key import urllib2 @@ -34,7 +34,7 @@ def _establish_connection(context_config): conn = connection if conn is None: # Store connection not bucket - conn = S3Connection( + conn = AsyncS3Connection( context_config.AWS_ACCESS_KEY, context_config.AWS_SECRET_KEY ) @@ -53,13 +53,15 @@ def load(context, url, callback): conn = _establish_connection(context.config) - bucket_loader = Bucket( + bucket_loader = AsyncBucket( connection=conn, name=bucket ) - file_key = bucket_loader.get_key(url) - if not file_key: - return callback(None) + def key_callback(file_key): + if file_key: + file_key.read(callback=callback) + else: + callback(None) - return callback(file_key.read()) + bucket_loader.get_key(url, callback=key_callback)