AsyncPipeline Class
Async pipeline implementation.
This is implemented as a context manager, that will activate the context of the HTTP sender.
- Inheritance
-
AsyncPipelineAsyncPipeline
Constructor
AsyncPipeline(transport: AsyncHttpTransport[HTTPRequestType, AsyncHTTPResponseType], policies: Iterable[AsyncHTTPPolicy[HTTPRequestType, AsyncHTTPResponseType] | SansIOHTTPPolicy[HTTPRequestType, AsyncHTTPResponseType]] | None = None)
Parameters
Name | Description |
---|---|
transport
Required
|
The async Http Transport instance. |
policies
|
List of configured policies. Default value: None
|
Examples
Builds the async pipeline for asynchronous transport.
from azure.core.pipeline import AsyncPipeline
from azure.core.pipeline.policies import AsyncRedirectPolicy, UserAgentPolicy
from azure.core.pipeline.transport import AioHttpTransport
from azure.core.rest import HttpRequest
# example: create request and policies
request = HttpRequest("GET", "https://bing.com")
policies: Iterable[Union[AsyncHTTPPolicy, SansIOHTTPPolicy]] = [
UserAgentPolicy("myuseragent"),
AsyncRedirectPolicy(),
]
# run the pipeline
async with AsyncPipeline(transport=AioHttpTransport(), policies=policies) as pipeline:
response = await pipeline.run(request)
Methods
run |
Runs the HTTP Request through the chained policies. |
run
Runs the HTTP Request through the chained policies.
async run(request: HTTPRequestType, **kwargs: Any) -> PipelineResponse[HTTPRequestType, AsyncHTTPResponseType]
Parameters
Name | Description |
---|---|
request
Required
|
The HTTP request object. |
Returns
Type | Description |
---|---|
The PipelineResponse object. |