From: Harmon Date: Wed, 19 May 2021 12:05:08 +0000 (-0500) Subject: Use ensure_future instead of create_task in AsyncStream X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=bd0b40398d0a3bd4c3b209f7e91f9de74e0d148e;p=tweepy.git Use ensure_future instead of create_task in AsyncStream Maintain support for Python 3.6 --- diff --git a/tweepy/asynchronous/streaming.py b/tweepy/asynchronous/streaming.py index 1c7a559..3a6b5a3 100644 --- a/tweepy/asynchronous/streaming.py +++ b/tweepy/asynchronous/streaming.py @@ -227,9 +227,10 @@ class AsyncStream: if stall_warnings: body["stall_warnings"] = "true" - self.task = asyncio.create_task( + self.task = asyncio.ensure_future( self._connect("POST", endpoint, headers=headers, body=body or None) ) + # Use create_task when support for Python 3.6 is dropped return self.task def sample(self, *, languages=None, stall_warnings=False): @@ -277,9 +278,10 @@ class AsyncStream: if stall_warnings: params["stall_warnings"] = "true" - self.task = asyncio.create_task( + self.task = asyncio.ensure_future( self._connect("GET", endpoint, params=params) ) + # Use create_task when support for Python 3.6 is dropped return self.task def disconnect(self):