diff options
author | Philipp Hörist <philipp@hoerist.com> | 2023-05-20 09:41:34 +0300 |
---|---|---|
committer | Philipp Hörist <philipp@hoerist.com> | 2023-05-20 09:41:34 +0300 |
commit | 1de40d394f1d9aa96f47db811698b31ce72ae3e3 (patch) | |
tree | d2a2a7f64e848482290acb158e93d80ddcaa473a | |
parent | 293480a8fb62edacea81b6322b731cbc78ffb163 (diff) |
cfix: HTTP: Exit async callbacks early if message is finished
-rw-r--r-- | nbxmpp/http.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/nbxmpp/http.py b/nbxmpp/http.py index 1a9ca70..2261618 100644 --- a/nbxmpp/http.py +++ b/nbxmpp/http.py @@ -312,6 +312,9 @@ class HTTPRequest(GObject.GObject): result: Gio.AsyncResult ) -> None: + if self._is_finished: + return + self._log.info('Request response received') try: self._input_stream = session.send_finish(result) @@ -347,6 +350,10 @@ class HTTPRequest(GObject.GObject): def _on_bytes_read_result(self, input_stream: Gio.InputStream, result: Gio.AsyncResult) -> None: + + if self._is_finished: + return + try: data = input_stream.read_bytes_finish(result) except GLib.Error as error: @@ -504,6 +511,7 @@ class HTTPRequest(GObject.GObject): self._error = HTTPRequestError.TIMEOUT else: self._error = error + self._close_all_streams() self.emit('finished') self._cleanup() |