From b117b9320d0d8117f5d5de703dd7af30a3de3b7b Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sat, 3 Oct 2015 14:37:02 +0800 Subject: [PATCH] asyncio.async -> asyncio.ensure_future --- artiq/frontend/artiq_gui.py | 2 +- artiq/gui/explorer.py | 11 +++++++---- artiq/gui/schedule.py | 2 +- artiq/master/repository.py | 2 +- artiq/test/sync_struct.py | 4 ++-- artiq/tools.py | 4 ++-- 6 files changed, 14 insertions(+), 11 deletions(-) diff --git a/artiq/frontend/artiq_gui.py b/artiq/frontend/artiq_gui.py index f6fbf7ebb..f6f9db57c 100755 --- a/artiq/frontend/artiq_gui.py +++ b/artiq/frontend/artiq_gui.py @@ -132,7 +132,7 @@ def main(): args.server, args.port_control, "master_pdb")) atexit.register(lambda: pdb.close_rpc()) def _get_parameter(k, v): - asyncio.async(pdb.set(k, v)) + asyncio.ensure_future(pdb.set(k, v)) d_console = ConsoleDock( d_params.get_parameter, _get_parameter, diff --git a/artiq/gui/explorer.py b/artiq/gui/explorer.py index bed58ae39..bf2fc3e69 100644 --- a/artiq/gui/explorer.py +++ b/artiq/gui/explorer.py @@ -338,7 +338,10 @@ class ExplorerDock(dockarea.Dock): arguments = self.argeditor.get_argument_values(True) if arguments is None: return - asyncio.async(self.submit(self.pipeline.text(), - expinfo["file"], expinfo["class_name"], - arguments, self.priority.value(), - due_date, self.flush.isChecked())) + asyncio.ensure_future(self.submit(self.pipeline.text(), + expinfo["file"], + expinfo["class_name"], + arguments, + self.priority.value(), + due_date, + self.flush.isChecked())) diff --git a/artiq/gui/schedule.py b/artiq/gui/schedule.py index ab11714c1..21ab02b88 100644 --- a/artiq/gui/schedule.py +++ b/artiq/gui/schedule.py @@ -99,4 +99,4 @@ class ScheduleDock(dockarea.Dock): row = idx[0].row() rid = self.table_model.row_to_key[row] self.status_bar.showMessage("Deleted RID {}".format(rid)) - asyncio.async(self.delete(rid)) + asyncio.ensure_future(self.delete(rid)) diff --git a/artiq/master/repository.py b/artiq/master/repository.py index 556232014..6478570c8 100644 --- a/artiq/master/repository.py +++ b/artiq/master/repository.py @@ -86,7 +86,7 @@ class Repository: self._scanning = False def scan_async(self, new_cur_rev=None): - asyncio.async(exc_to_warning(self.scan(new_cur_rev))) + asyncio.ensure_future(exc_to_warning(self.scan(new_cur_rev))) class FilesystemBackend: diff --git a/artiq/test/sync_struct.py b/artiq/test/sync_struct.py index d8b229d7e..3f30062ff 100644 --- a/artiq/test/sync_struct.py +++ b/artiq/test/sync_struct.py @@ -59,7 +59,7 @@ class SyncStructCase(unittest.TestCase): self.receiving_done = asyncio.Event() publisher = asyncio.Future() test_dict = asyncio.Future() - asyncio.async(start_server(publisher, test_dict)) + asyncio.ensure_future(start_server(publisher, test_dict)) loop.run_until_complete(publisher) loop.run_until_complete(test_dict) @@ -68,7 +68,7 @@ class SyncStructCase(unittest.TestCase): test_vector = dict() loop.run_until_complete(write_test_data(test_vector)) - asyncio.async(write_test_data(test_dict)) + asyncio.ensure_future(write_test_data(test_dict)) self.subscriber = sync_struct.Subscriber("test", self.init_test_dict, self.notify) loop.run_until_complete(self.subscriber.connect(test_address, diff --git a/artiq/tools.py b/artiq/tools.py index 321c87bfe..e89910e20 100644 --- a/artiq/tools.py +++ b/artiq/tools.py @@ -90,7 +90,7 @@ def exc_to_warning(coro): @asyncio.coroutine def asyncio_wait_or_cancel(fs, **kwargs): - fs = [asyncio.async(f) for f in fs] + fs = [asyncio.ensure_future(f) for f in fs] try: d, p = yield from asyncio.wait(fs, **kwargs) except: @@ -105,7 +105,7 @@ def asyncio_wait_or_cancel(fs, **kwargs): class TaskObject: def start(self): - self.task = asyncio.async(self._do()) + self.task = asyncio.ensure_future(self._do()) @asyncio.coroutine def stop(self):