Philipp Hörist pushed to branch master at gajim / python-nbxmpp
Commits: eab25fc9 by lovetox at 2020-04-16T14:39:06+02:00 TCP: Add debug logging for keepalive timer
- - - - - 136dfd21 by lovetox at 2020-04-16T16:38:38+02:00 TCP: Refactor write async callback
- - - - -
1 changed file:
- nbxmpp/tcp.py
Changes:
===================================== nbxmpp/tcp.py ===================================== @@ -143,11 +143,15 @@ class TCPConnection(Connection):
def _remove_keepalive_timer(self): if self._keepalive_id is not None: + self._log.info('Remove keepalive timer') GLib.source_remove(self._keepalive_id) self._keepalive_id = None
def _renew_keepalive_timer(self): + if self._con is None: + return self._remove_keepalive_timer() + self._log.info('Add keepalive timer') self._keepalive_id = GLib.timeout_add_seconds(5, self._send_keepalive)
def _send_keepalive(self): @@ -280,22 +284,19 @@ class TCPConnection(Connection): self._log.error('Write Error: %s', error) return
- self._renew_keepalive_timer() - data = data.decode() + self._log_stanza(data, received=False) + if data == ' ': # keepalive whitespace - if self._write_queue: - self._write_stanzas() - return - - self._log_stanza(data, received=False) + self._renew_keepalive_timer()
- for stanza in self._write_stanza_buffer: - try: - self.notify('data-sent', stanza) - except Exception: - self._log.exception('Error while executing data-sent:') + else: + for stanza in self._write_stanza_buffer: + try: + self.notify('data-sent', stanza) + except Exception: + self._log.exception('Error while executing data-sent:')
if self._output_closed and not self._write_queue: self._check_for_shutdown() @@ -363,3 +364,4 @@ class TCPConnection(Connection): super().destroy() self._con = None self._client = None + self._write_queue = None
View it on GitLab: https://dev.gajim.org/gajim/python-nbxmpp/-/compare/857ab2bb5ee89d00e747ea89...