1. 获取loop直到异步执行完毕
import asyncio
def loop_run_task(ip, command):
# loop = asyncio.get_event_loop()
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
content = loop.run_until_complete(task_execute_shell(ip, command))
loop.close()
return
微信扫一扫
import asyncio
def loop_run_task(ip, command):
# loop = asyncio.get_event_loop()
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
content = loop.run_until_complete(task_execute_shell(ip, command))
loop.close()
return
相关推荐