Skip to content

Commit d1db539

Browse files
macsirMariusWirtz
authored andcommitted
Remove unused tcp_keepalive variable from wrapper
1 parent a340b6a commit d1db539

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

TM1py/Services/RestService.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ def httpmethod(func):
3636
"""
3737

3838
@functools.wraps(func)
39-
def wrapper(self, url: str, data: str = '', encoding='utf-8', async_requests_mode: Optional[bool] = None,
40-
tcp_keepalive: Optional[bool] = None, **kwargs):
39+
def wrapper(self, url: str, data: str = '', encoding='utf-8', async_requests_mode: Optional[bool] = None, **kwargs):
4140
# url encoding
4241
url, data = self._url_and_body(
4342
url=url,
@@ -49,18 +48,13 @@ def wrapper(self, url: str, data: str = '', encoding='utf-8', async_requests_mod
4948
if async_requests_mode is None:
5049
async_requests_mode = self._async_requests_mode
5150

52-
if tcp_keepalive is None:
53-
tcp_keepalive = self._tcp_keepalive
54-
5551
if not async_requests_mode:
5652
response = func(self, url, data, **kwargs)
5753
if self._re_connect_on_session_timeout and response.status_code == 401:
5854
self.connect()
5955
response = func(self, url, data, **kwargs)
6056

6157
else:
62-
# reset tcp_keepalive to False explicitly to turn it off when async_requests_mode is enabled
63-
tcp_keepalive = False
6458
additional_header = {'Prefer': 'respond-async'}
6559
http_headers = kwargs.get('headers', dict())
6660
http_headers.update(additional_header)
@@ -185,7 +179,8 @@ def __init__(self, **kwargs):
185179
self._verify = False
186180
self._timeout = None if kwargs.get('timeout', None) is None else float(kwargs.get('timeout'))
187181
self._async_requests_mode = self.translate_to_boolean(kwargs.get('async_requests_mode', False))
188-
self._tcp_keepalive = self.translate_to_boolean(kwargs.get('tcp_keepalive', False))
182+
# Set tcp_keepalive to False explicitly to turn it off when async_requests_mode is enabled
183+
self._tcp_keepalive = self.translate_to_boolean(kwargs.get('tcp_keepalive', False)) if self._async_requests_mode is not True else False
189184
self._connection_pool_size = kwargs.get('connection_pool_size', None)
190185
self._re_connect_on_session_timeout = kwargs.get('re_connect_on_session_timeout', True)
191186
# populated on the fly

0 commit comments

Comments
 (0)