Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Apr 15, 2024. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions 17 consul/aio.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@
class HTTPClient(base.HTTPClient):
"""Asyncio adapter for python consul using aiohttp library"""

def __init__(self, *args, loop=None, **kwargs):
def __init__(self, *args, loop=None, client_session=None, **kwargs):
super(HTTPClient, self).__init__(*args, **kwargs)
self._loop = loop or asyncio.get_event_loop()
connector = aiohttp.TCPConnector(loop=self._loop,
verify_ssl=self.verify)
self._session = aiohttp.ClientSession(connector=connector)
if client_session:
self._session = client_session
else:
connector = aiohttp.TCPConnector(loop=self._loop,
verify_ssl=self.verify)
self._session = aiohttp.ClientSession(connector=connector)

@asyncio.coroutine
def _request(self, callback, method, uri, data=None):
Expand Down Expand Up @@ -60,13 +63,15 @@ def close(self):

class Consul(base.Consul):

def __init__(self, *args, loop=None, **kwargs):
def __init__(self, *args, loop=None, client_session=None, **kwargs):
self._loop = loop or asyncio.get_event_loop()
self._client_session = client_session
super().__init__(*args, **kwargs)

def connect(self, host, port, scheme, verify=True, cert=None):
return HTTPClient(host, port, scheme, loop=self._loop,
verify=verify, cert=None)
verify=verify, cert=None,
client_session=self._client_session)

def close(self):
"""Close all opened http connections"""
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.