Skip to content

Commit 3532651

Browse files
committed
Make AsyncTransport the default transport for AsyncClient
1 parent d7095b5 commit 3532651

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

examples/async_client.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ def handle_future(future):
1818

1919
loop = asyncio.get_event_loop()
2020

21-
transport = AsyncTransport(cache=None)
22-
client = zeep.AsyncClient("http://localhost:8000/?wsdl", transport=transport)
21+
client = zeep.AsyncClient("http://localhost:8000/?wsdl")
2322

2423
tasks = [
2524
client.service.slow_request("request-1"), # takes 1 sec
@@ -32,7 +31,7 @@ def handle_future(future):
3231

3332
st = time.time()
3433
loop.run_until_complete(future)
35-
loop.run_until_complete(transport.aclose())
34+
loop.run_until_complete(client.transport.aclose())
3635
print("time: %.2f" % (time.time() - st))
3736
print("result: %s", result)
3837
print("")

src/zeep/client.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from zeep.proxy import ServiceProxy, AsyncServiceProxy
55
from zeep.settings import Settings
6-
from zeep.transports import Transport
6+
from zeep.transports import AsyncTransport, Transport
77
from zeep.wsdl import Document
88

99
logger = logging.getLogger(__name__)
@@ -50,6 +50,8 @@ class Client:
5050
:param settings: a zeep.Settings() object
5151
5252
"""
53+
_default_transport = Transport
54+
5355
def __init__(
5456
self,
5557
wsdl,
@@ -64,7 +66,7 @@ def __init__(
6466
raise ValueError("No URL given for the wsdl")
6567

6668
self.settings = settings or Settings()
67-
self.transport = transport if transport is not None else Transport()
69+
self.transport = transport if transport is not None else self._default_transport()
6870
self.wsdl = Document(wsdl, self.transport, settings=self.settings)
6971
self.wsse = wsse
7072
self.plugins = plugins if plugins is not None else []
@@ -210,6 +212,7 @@ def _get_service(self, name: typing.Optional[str]) -> str:
210212

211213

212214
class AsyncClient(Client):
215+
_default_transport = AsyncTransport
213216

214217
def bind(
215218
self,

0 commit comments

Comments
 (0)