asyncio.ensure_future Python 3.5 (#13141)

This commit is contained in:
Otto Winter 2018-03-12 19:42:08 +01:00 committed by GitHub
parent 9ee123f5ce
commit 890197e407
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 14 deletions

View file

@ -189,12 +189,7 @@ class SpcWebGateway:
def start_listener(self, async_callback, *args):
"""Start the websocket listener."""
try:
from asyncio import ensure_future
except ImportError:
from asyncio import async as ensure_future
ensure_future(self._ws_listen(async_callback, *args))
asyncio.ensure_future(self._ws_listen(async_callback, *args))
def _build_url(self, resource):
return urljoin(self._api_url, "spc/{}".format(resource))

View file

@ -5,14 +5,7 @@ import logging
from asyncio import coroutines
from asyncio.futures import Future
try:
# pylint: disable=ungrouped-imports
from asyncio import ensure_future
except ImportError:
# Python 3.4.3 and earlier has this as async
# pylint: disable=unused-import
from asyncio import async
ensure_future = async
from asyncio import ensure_future
_LOGGER = logging.getLogger(__name__)