Skip to content
Prev Previous commit
Next Next commit
Fixed async transport sleep coroutine
  • Loading branch information
annatisch committed Jul 25, 2019
commit 9fee28c91d434e9c9480f0504d243912ceb7c021
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ async def __aenter__(self):
async def __aexit__(self, *exc_details): # pylint: disable=arguments-differ
return super(AsyncioRequestsTransport, self).__exit__()

async def sleep(self, duration):
await asyncio.sleep(duration)

async def send(self, request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: # type: ignore
"""Send the request using this HTTP sender.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ async def __aexit__(self, *exc_details): # pylint: disable=arguments-differ
return super(TrioRequestsTransport, self).__exit__()

async def sleep(self, duration):
await trio.sleep(duration)
return super(TrioRequestsTransport, self).sleep(duration)

async def send(self, request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: # type: ignore
"""Send the request using this HTTP sender.
Expand Down
12 changes: 12 additions & 0 deletions sdk/core/azure-core/tests/azure_core_asynctests/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,18 @@ async def test_basic_async_requests():

assert response.http_response.status_code == 200

@pytest.mark.asyncio
async def test_async_transport_sleep():

async with AsyncioRequestsTransport() as transport:
await transport.sleep(1)

async with AioHttpTransport() as transport:
await transport.sleep(1)

async with TrioRequestsTransport() as transport:
await transport.sleep(1)

@pytest.mark.asyncio
async def test_conf_async_requests():

Expand Down