Skip to content

Commit

Permalink
fix: aiohttpclient session
Browse files Browse the repository at this point in the history
  • Loading branch information
overcat committed Aug 12, 2019
1 parent 7f53c6a commit bc9d3a0
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ A Simple Example
transaction.sign(alice_keypair)
response = await server.submit_transaction(transaction)
print(response)
print(response)
if __name__ == "__main__":
Expand Down
28 changes: 14 additions & 14 deletions stellar_sdk/client/aiohttp_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ async def get(self, url: str, params: Dict[str, str] = None) -> Response:
:raise: :exc:`ConnectionError <stellar_sdk.exceptions.ConnectionError>`
"""
try:
async with self._session.get(url, params=params) as response:
return Response(
status_code=response.status,
text=await response.text(),
headers=dict(response.headers),
url=str(response.url),
)
response = await self._session.get(url, params=params)
return Response(
status_code=response.status,
text=await response.text(),
headers=dict(response.headers),
url=str(response.url),
)
except aiohttp.ClientConnectionError as e: # TODO: need more research
raise ConnectionError(e)

Expand All @@ -95,13 +95,13 @@ async def post(self, url: str, data: Dict[str, str] = None) -> Response:
:raise: :exc:`ConnectionError <stellar_sdk.exceptions.ConnectionError>`
"""
try:
async with self._session.post(url, data=data) as response:
return Response(
status_code=response.status,
text=await response.text(),
headers=dict(response.headers),
url=str(response.url),
)
response = await self._session.post(url, data=data)
return Response(
status_code=response.status,
text=await response.text(),
headers=dict(response.headers),
url=str(response.url),
)
except aiohttp.ClientConnectionError as e:
raise ConnectionError(e)

Expand Down
32 changes: 16 additions & 16 deletions stellar_sdk/client/requests_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ class RequestsClient(BaseSyncClient):
"""

def __init__(
self,
pool_size: int = DEFAULT_POOLSIZE,
num_retries: int = DEFAULT_NUM_RETRIES,
request_timeout: int = DEFAULT_REQUEST_TIMEOUT,
backoff_factor: float = DEFAULT_BACKOFF_FACTOR,
session: Session = None,
stream_session: Session = None,
self,
pool_size: int = DEFAULT_POOLSIZE,
num_retries: int = DEFAULT_NUM_RETRIES,
request_timeout: int = DEFAULT_REQUEST_TIMEOUT,
backoff_factor: float = DEFAULT_BACKOFF_FACTOR,
session: Session = None,
stream_session: Session = None,
):
self.pool_size = pool_size
self.num_retries = num_retries
Expand Down Expand Up @@ -143,7 +143,7 @@ def post(self, url: str, data: Dict[str, str] = None) -> Response:
)

def stream(
self, url: str, params: Dict[str, str] = None
self, url: str, params: Dict[str, str] = None
) -> Generator[Dict[str, Any], None, None]:
"""Creates an EventSource that listens for incoming messages from the server.
Expand Down Expand Up @@ -186,14 +186,14 @@ def __exit__(self, exc_type, exc_val, exc_tb):

class _SSEClient:
def __init__(
self,
url: str,
last_id: Union[str, int] = None,
retry: int = 3000,
session: Session = None,
chunk_size: int = 1024,
connect_retry: int = 0,
**kwargs
self,
url: str,
last_id: Union[str, int] = None,
retry: int = 3000,
session: Session = None,
chunk_size: int = 1024,
connect_retry: int = 0,
**kwargs
):
if SSEClient is None:
raise ImportError(
Expand Down
4 changes: 2 additions & 2 deletions stellar_sdk/operation/create_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class CreateAccount(Operation):
:param destination: Destination account ID to create an account for.
:param starting_balance: Amount in XLM the account should be
funded for. Must be greater than the [reserve balance amount]
(https://www.stellar.org/developers/learn/concepts/fees.html).
funded for. Must be greater than the `reserve balance amount
<https://www.stellar.org/developers/learn/concepts/fees.html>`_.
:param source: The source account for the payment. Defaults to the
transaction's source account.
Expand Down

0 comments on commit bc9d3a0

Please sign in to comment.