From a9f2897f70bc3f23a3d574d438524be52a6d68cb Mon Sep 17 00:00:00 2001 From: Harmon Date: Tue, 26 Jan 2021 09:39:22 -0600 Subject: [PATCH] Fix disconnect message handling in AsyncStream.on_data --- tweepy/asynchronous/streaming.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tweepy/asynchronous/streaming.py b/tweepy/asynchronous/streaming.py index dd6cbb2..150c617 100644 --- a/tweepy/asynchronous/streaming.py +++ b/tweepy/asynchronous/streaming.py @@ -291,10 +291,12 @@ class AsyncStream: if "delete" in data: delete = data["delete"]["status"] return await self.on_delete(delete["id"], delete["user_id"]) + if "disconnect" in data: + return await self.on_disconnect_message(data["disconnect"]) if "limit" in data: return await self.on_limit(data["limit"]["track"]) - for message_type in ("disconnect_message", "scrub_geo", - "status_withheld", "user_withheld", "warning"): + for message_type in ("scrub_geo","status_withheld", "user_withheld", + "warning"): if message_type in data: method = getattr(self, "on_" + message_type) return await method(data[message_type]) -- 2.25.1