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'] +) 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)