ivandasch commented on a change in pull request #2:
URL: 
https://github.com/apache/ignite-python-thin-client/pull/2#discussion_r560825013



##########
File path: pyignite/connection/__init__.py
##########
@@ -131,47 +142,186 @@ def __init__(self, prefetch: bytes=b'', **kwargs):
          cluster,
         :param password: (optional) password to authenticate to Ignite cluster.
         """
+        self.client = client
         self.prefetch = prefetch
-        self._check_kwargs(kwargs)
-        self.timeout = kwargs.pop('timeout', None)
-        self.username = kwargs.pop('username', None)
-        self.password = kwargs.pop('password', None)
-        if all([self.username, self.password, 'use_ssl' not in kwargs]):
-            kwargs['use_ssl'] = True
-        self.init_kwargs = kwargs
-
-    read_response = read_response
-    _wrap = wrap
+        self.timeout = timeout
+        self.username = username
+        self.password = password
+        self._check_ssl_params(ssl_params)
+        if all([self.username, self.password, 'use_ssl' not in ssl_params]):
+            ssl_params['use_ssl'] = True
+        self.ssl_params = ssl_params
+        self._failed = False
+        self._in_use = Lock()
 
     @property
     def socket(self) -> socket.socket:
-        """
-        Network socket.
-        """
-        if self._socket is None:
-            self._reconnect()
+        """ Network socket. """
         return self._socket
 
+    @property
+    def closed(self) -> bool:
+        """ Tells if socket is closed. """
+        return self._socket is None
+
+    @property
+    def failed(self) -> bool:
+        """ Tells if connection is failed. """
+        return self._failed
+
+    @property
+    def alive(self) -> bool:
+        """ Tells if connection is up and no failure detected. """
+        return not (self._failed or self.closed)
+
     def __repr__(self) -> str:
-        if self.host and self.port:
-            return '{}:{}'.format(self.host, self.port)
+        return '{}:{}'.format(self.host or '?', self.port or '?')
+
+    _wrap = wrap
+
+    def get_protocol_version(self):
+        """
+        Returns the tuple of major, minor, and revision numbers of the used
+        thin protocol version, or None, if no connection to the Ignite cluster
+        was yet established.
+        """
+        return self.client.protocol_version
+
+    def _fail(self):
+        """ set client to failed state. """
+        self._failed = True
+        self._in_use.release()
+
+    @select_version

Review comment:
       Same as above, this is anti-pattern




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to