SiyaoIsHiding commented on code in PR #1285:
URL:
https://github.com/apache/cassandra-python-driver/pull/1285#discussion_r3089273653
##########
cassandra/cluster.py:
##########
@@ -3748,6 +3749,15 @@ def _try_connect(self, host):
return connection
+ def _handle_graceful_disconnect(self, event):
+ if self._connection is None:
+ return
+ host = self._cluster.metadata.get_host(self._connection.endpoint)
+ print("host found:", host)
Review Comment:
We need to remove those print statements before we merge the PR for sure
##########
cassandra/connection.py:
##########
@@ -1061,16 +1064,29 @@ def get_request_id(self):
return self.highest_request_id
def handle_pushed(self, response):
+ if response.event_type == 'GRACEFUL_DISCONNECT':
+ self._handle_graceful_disconnect()
log.debug("Message pushed from server: %r", response)
for cb in self._push_watchers.get(response.event_type, []):
try:
cb(response.event_args)
except Exception:
log.exception("Pushed event handler errored, ignoring:")
+ def _handle_graceful_disconnect(self):
+ log.info("Received GRACEFUL_DISCONNECT from %s. Draining
connection...", self.endpoint)
+ self.is_draining = True
+ self._socket_writable = False
+
+ with self.lock:
+ if self.in_flight == 0:
Review Comment:
For the several occurrences of `if self.in_flight == 0:` in this PR,
If `self.in_flight == 0` is evaluated as false at that time, will the code
_wait_ and evaluate `self.in_filght == 0` again?
##########
cassandra/connection.py:
##########
@@ -1397,6 +1413,7 @@ def _handle_options_response(self, options_response):
locally_supported_compressions[compression_type]
self._send_startup_message(compression_type,
no_compact=self.no_compact)
+ self.supports_graceful_disconnect =
options_response.options.get('GRACEFUL_DISCONNECT') == ['true']
Review Comment:
Wondering where is the code that regsiters to listen on the
GRACEFUL_DISCONNECT event?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]