Use asyncio.ensure_future() instead of asyncio.async() with conservative approach to support Python < 3.4.4. Fixes https://github.com/GNS3/gns3-gui/issues/2566

This commit is contained in:
grossmj committed 2018-08-24 18:57:18 +07:00
1 parent a3d1e865a8
commit 3560cda06c
17 files changed
+63 -38

No files matched your search

+2 -1
View File
@@ -30,6 +30,7 @@ log = logging.getLogger(__name__)
from uuid import UUID, uuid4
from gns3server.utils.interfaces import is_interface_up
from gns3server.utils.asyncio import asyncio_ensure_future
from ..config import Config
from ..utils.asyncio import wait_run_in_executor
from ..utils import force_unix_path
@@ -127,7 +128,7 @@ class BaseManager:
tasks = []
for node_id in self._nodes.keys():
tasks.append(asyncio.async(self.close_node(node_id)))
tasks.append(asyncio_ensure_future(self.close_node(node_id)))
if tasks:
done, _ = yield from asyncio.wait(tasks)
+2 -1
View File
@@ -29,6 +29,7 @@ import os
from gns3server.utils.asyncio.telnet_server import AsyncioTelnetServer
from gns3server.utils.asyncio.raw_command_server import AsyncioRawCommandServer
from gns3server.utils.asyncio import wait_for_file_creation
from gns3server.utils.asyncio import asyncio_ensure_future
from gns3server.utils.get_resource import get_resource
from gns3server.ubridge.ubridge_error import UbridgeError, UbridgeNamespaceError
@@ -567,7 +568,7 @@ class DockerVM(BaseNode):
output_stream.feed_data(self.name.encode() + b" console is now available... Press RETURN to get started.\r\n")
asyncio.async(self._read_console_output(self._console_websocket, output_stream))
asyncio_ensure_future(self._read_console_output(self._console_websocket, output_stream))
@asyncio.coroutine
def _read_console_output(self, ws, out):
+3 -2
View File
@@ -36,6 +36,7 @@ log = logging.getLogger(__name__)
from gns3server.utils.interfaces import interfaces, is_interface_up
from gns3server.utils.asyncio import wait_run_in_executor
from gns3server.utils import parse_version
from gns3server.utils.asyncio import asyncio_ensure_future
from uuid import uuid4
from ..base_manager import BaseManager
from ..port_manager import PortManager
@@ -172,7 +173,7 @@ class Dynamips(BaseManager):
tasks = []
for device in self._devices.values():
tasks.append(asyncio.async(device.hypervisor.stop()))
tasks.append(asyncio_ensure_future(device.hypervisor.stop()))
if tasks:
done, _ = yield from asyncio.wait(tasks)
@@ -196,7 +197,7 @@ class Dynamips(BaseManager):
tasks = []
for device in self._devices.values():
if device.project.id == project.id:
tasks.append(asyncio.async(device.delete()))
tasks.append(asyncio_ensure_future(device.delete()))
if tasks:
done, _ = yield from asyncio.wait(tasks)
+2 -2
View File
@@ -40,7 +40,7 @@ from ..nios.nio_udp import NIOUDP
from gns3server.utils.file_watcher import FileWatcher
from gns3server.utils.asyncio import wait_run_in_executor, monitor_process
from gns3server.utils.asyncio import wait_run_in_executor, monitor_process, asyncio_ensure_future
from gns3server.utils.images import md5sum
@@ -196,7 +196,7 @@ class Router(BaseNode):
"""
Called when the NVRAM file has changed
"""
asyncio.async(self.save_configs())
asyncio_ensure_future(self.save_configs())
@property
def dynamips_id(self):
+2 -2
View File
@@ -29,7 +29,7 @@ from uuid import UUID, uuid4
from .port_manager import PortManager
from .notification_manager import NotificationManager
from ..config import Config
from ..utils.asyncio import wait_run_in_executor
from ..utils.asyncio import wait_run_in_executor, asyncio_ensure_future
from ..utils.path import check_path_allowed, get_default_project_directory
import logging
@@ -346,7 +346,7 @@ class Project:
tasks = []
for node in self._nodes:
tasks.append(asyncio.async(node.manager.close_node(node.id)))
tasks.append(asyncio_ensure_future(node.manager.close_node(node.id)))
if tasks:
done, _ = yield from asyncio.wait(tasks)
+2 -1
View File
@@ -32,6 +32,7 @@ import shlex
from collections import OrderedDict
from gns3server.utils.interfaces import interfaces
from gns3server.utils.asyncio import subprocess_check_output
from gns3server.utils.asyncio import asyncio_ensure_future
from gns3server.utils import parse_version
log = logging.getLogger(__name__)
@@ -738,4 +739,4 @@ if __name__ == '__main__':
loop = asyncio.get_event_loop()
vmware = VMware.instance()
print("=> Check version")
loop.run_until_complete(asyncio.async(vmware.check_vmware_version()))
loop.run_until_complete(asyncio_ensure_future(vmware.check_vmware_version()))