Giter Club home page Giter Club logo

botocore-tornado's Introduction

botocore-tornado

This module provides subclasses of botocore classes that use the tornado AsyncHTTPClient to make requests. As far as possible, the api is kept the same as the botocore api, the only difference is that Operation.call returns a Future that is resolved when the http request is complete.

Installation

pip install botocore-tornado

Example

Uploading a file to S3:

import botocore.session

session = botocore.session.get_session()
s3 = session.get_service('s3')
endpoint = s3.get_endpoint(region)

fp = open('./testfile.txt', 'rb')
operation = s3.get_operation('PutObject')
http_response, response_data = operation.call(endpoint,
                                              bucket=bucket,
                                              key=key + '/' + filename,
                                              body=fp)

Using botocore-tornado:

from tornado.ioloop import IOLoop
from tornado import gen
import botocore_tornado.session

@gen.coroutine
def main_async():
    session = botocore_tornado.session.get_session()
    s3 = session.get_service('s3')
    endpoint = s3.get_endpoint(region)

    fp = open('./testfile.txt', 'rb')
    operation = s3.get_operation('PutObject')
    http_response, response_data = yield operation.call(endpoint,
                                                        bucket=bucket,
                                                        key=key + '/' + filename,
                                                        body=fp)
    print response_data

IOLoop.instance().run_sync(main_async)

botocore-tornado's People

Contributors

nschlemm avatar sjhewitt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

botocore-tornado's Issues

Typo in example

If I'm wrong, forgive, but it looks like your example has a typo in the imports.
import tornado_botocore.session should be import botocore_tornado.session

botocore requirement needs to be pinned to same version

Otherwise, one might unknowingly install a current version of botocore which recently introduced breaking api changes described on https://botocore.readthedocs.org/en/latest/client_upgrades.html#client-upgrades

Quick fix for users: explicitly pin botocore to same version as botocore_tornado (currently 0.93.0) in your requirements

Quick fix for maintainer: pin version in https://github.com/qudos-com/botocore-tornado/blob/master/setup.py#L31 stricter

Ideal fix: follow api changes linked above in botocore_tornado

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.