Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Allow for providing our own ioloop #4

Merged
merged 1 commit into from over 1 year ago

2 participants

Rhett Garber Dan Frank
Rhett Garber

Using the global default ioloop doesn't alway work. This just adds optional arguments.

Dan Frank

sorry 4 the wait

Dan Frank danielhfrank merged commit ccbe547 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Apr 06, 2012
Rhett Garber rhettg Allow for caller defined ioloop 344ec96
This page is out of date. Refresh to see the latest.
6 asyncdynamo/async_aws_sts.py
@@ -48,13 +48,13 @@ def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
48 48 is_secure=True, port=None, proxy=None, proxy_port=None,
49 49 proxy_user=None, proxy_pass=None, debug=0,
50 50 https_connection_factory=None, region=None, path='/',
51   - converter=None):
  51 + converter=None, ioloop=None):
52 52 STSConnection.__init__(self, aws_access_key_id,
53 53 aws_secret_access_key,
54 54 is_secure, port, proxy, proxy_port,
55 55 proxy_user, proxy_pass, debug,
56 56 https_connection_factory, region, path, converter)
57   - self.http_client = AsyncHTTPClient()
  57 + self.http_client = AsyncHTTPClient(io_loop=ioloop)
58 58
59 59 def get_session_token(self, callback):
60 60 '''
@@ -112,4 +112,4 @@ def make_request(self, action, params={}, path='/', verb='GET', callback=None):
112 112 def _finish_make_request(self, response, callback):
113 113 if response.error:
114 114 return callback(response.body, error=response.error)
115   - return callback(response.body)
  115 + return callback(response.body)
9 asyncdynamo/asyncdynamo.py
@@ -77,7 +77,7 @@ class AsyncDynamoDB(AWSAuthConnection):
77 77 def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
78 78 is_secure=True, port=None, proxy=None, proxy_port=None,
79 79 host=None, debug=0, session_token=None,
80   - authenticate_requests=True, validate_cert=True, max_sts_attempts=3):
  80 + authenticate_requests=True, validate_cert=True, max_sts_attempts=3, ioloop=None):
81 81 if not host:
82 82 host = self.DefaultHost
83 83 self.validate_cert = validate_cert
@@ -87,9 +87,10 @@ def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
87 87 aws_secret_access_key,
88 88 is_secure, port, proxy, proxy_port,
89 89 debug=debug, security_token=session_token)
90   - self.http_client = AsyncHTTPClient()
  90 + self.ioloop = ioloop or IOLoop.instance()
  91 + self.http_client = AsyncHTTPClient(io_loop=self.ioloop)
91 92 self.pending_requests = deque()
92   - self.sts = AsyncAwsSts(aws_access_key_id, aws_secret_access_key)
  93 + self.sts = AsyncAwsSts(aws_access_key_id, aws_secret_access_key, ioloop=self.ioloop)
93 94 assert (isinstance(max_sts_attempts, int) and max_sts_attempts >= 0)
94 95 self.max_sts_attempts = max_sts_attempts
95 96
@@ -141,7 +142,7 @@ def raise_error():
141 142 else:
142 143 seconds_to_wait = (0.1*(2**attempts))
143 144 logging.warning("Got error[ %s ] getting session token, retrying in %.02f seconds" % (error, seconds_to_wait))
144   - IOLoop.instance().add_timeout(time.time() + seconds_to_wait,
  145 + self.ioloop.add_timeout(time.time() + seconds_to_wait,
145 146 functools.partial(self._update_session_token, attempts=attempts+1, callback=callback, bypass_lock=True))
146 147 return
147 148 else:

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.