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"))
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,

View File

@ -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()))

View File

@ -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))

View File

@ -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:

View File

@ -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,

View File

@ -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):