Skip to content

Commit

Permalink
Fix error when closing session in transport destructor
Browse files Browse the repository at this point in the history
Fixes #1347
  • Loading branch information
mvantellingen committed Nov 10, 2022
1 parent 09019c8 commit 7d22412
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 5 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
4.2.0 (2022-111-03)
4.2.1 (2022-11-10)
-------------------
- Fix error regarding closing session in async transport (#1347)

4.2.0 (2022-11-03)
-------------------
- Drop support for Python 3.6
- Allow embedding CDATA elements in simple types (#1339)
Expand Down
5 changes: 3 additions & 2 deletions src/zeep/transports.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def __init__(self, cache=None, timeout=300, operation_timeout=None, session=None
self.operation_timeout = operation_timeout
self.logger = logging.getLogger(__name__)

self.__close_session = not session
self._close_session = not session
self.session = session or requests.Session()
self.session.mount("file://", FileAdapter())
self.session.headers["User-Agent"] = "Zeep/%s (www.python-zeep.org)" % (
Expand Down Expand Up @@ -156,7 +156,7 @@ def settings(self, timeout=None):
self.operation_timeout = old_timeout

def __del__(self):
if self.__close_session:
if self._close_session:
self.session.close()


Expand All @@ -181,6 +181,7 @@ def __init__(
if httpx is None:
raise RuntimeError("The AsyncTransport is based on the httpx module")

self._close_session = False
self.cache = cache
self.wsdl_client = wsdl_client or httpx.Client(
verify=verify_ssl,
Expand Down

0 comments on commit 7d22412

Please sign in to comment.