asyncio.async -> asyncio.ensure_future

This commit is contained in:
Sebastien Bourdeauducq 2015-10-03 14:37:02 +08:00
parent 125503139e
commit b117b9320d
6 changed files with 14 additions and 11 deletions

View File

@ -132,7 +132,7 @@ def main():
args.server, args.port_control, "master_pdb")) args.server, args.port_control, "master_pdb"))
atexit.register(lambda: pdb.close_rpc()) atexit.register(lambda: pdb.close_rpc())
def _get_parameter(k, v): def _get_parameter(k, v):
asyncio.async(pdb.set(k, v)) asyncio.ensure_future(pdb.set(k, v))
d_console = ConsoleDock( d_console = ConsoleDock(
d_params.get_parameter, d_params.get_parameter,
_get_parameter, _get_parameter,

View File

@ -338,7 +338,10 @@ class ExplorerDock(dockarea.Dock):
arguments = self.argeditor.get_argument_values(True) arguments = self.argeditor.get_argument_values(True)
if arguments is None: if arguments is None:
return return
asyncio.async(self.submit(self.pipeline.text(), asyncio.ensure_future(self.submit(self.pipeline.text(),
expinfo["file"], expinfo["class_name"], expinfo["file"],
arguments, self.priority.value(), expinfo["class_name"],
due_date, self.flush.isChecked())) arguments,
self.priority.value(),
due_date,
self.flush.isChecked()))

View File

@ -99,4 +99,4 @@ class ScheduleDock(dockarea.Dock):
row = idx[0].row() row = idx[0].row()
rid = self.table_model.row_to_key[row] rid = self.table_model.row_to_key[row]
self.status_bar.showMessage("Deleted RID {}".format(rid)) self.status_bar.showMessage("Deleted RID {}".format(rid))
asyncio.async(self.delete(rid)) asyncio.ensure_future(self.delete(rid))

View File

@ -86,7 +86,7 @@ class Repository:
self._scanning = False self._scanning = False
def scan_async(self, new_cur_rev=None): 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: class FilesystemBackend:

View File

@ -59,7 +59,7 @@ class SyncStructCase(unittest.TestCase):
self.receiving_done = asyncio.Event() self.receiving_done = asyncio.Event()
publisher = asyncio.Future() publisher = asyncio.Future()
test_dict = 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(publisher)
loop.run_until_complete(test_dict) loop.run_until_complete(test_dict)
@ -68,7 +68,7 @@ class SyncStructCase(unittest.TestCase):
test_vector = dict() test_vector = dict()
loop.run_until_complete(write_test_data(test_vector)) 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.subscriber = sync_struct.Subscriber("test", self.init_test_dict,
self.notify) self.notify)
loop.run_until_complete(self.subscriber.connect(test_address, loop.run_until_complete(self.subscriber.connect(test_address,

View File

@ -90,7 +90,7 @@ def exc_to_warning(coro):
@asyncio.coroutine @asyncio.coroutine
def asyncio_wait_or_cancel(fs, **kwargs): 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: try:
d, p = yield from asyncio.wait(fs, **kwargs) d, p = yield from asyncio.wait(fs, **kwargs)
except: except:
@ -105,7 +105,7 @@ def asyncio_wait_or_cancel(fs, **kwargs):
class TaskObject: class TaskObject:
def start(self): def start(self):
self.task = asyncio.async(self._do()) self.task = asyncio.ensure_future(self._do())
@asyncio.coroutine @asyncio.coroutine
def stop(self): def stop(self):