1. 10秒钟测试ip段所有IP的连通性
(base) [root@wlt-overseas-middleware-master ~]# cat su-asyncio-re-cancel.py import asyncio import time import re # call shell cmd and get exec return code async def run(cmd): proc = await asyncio.subprocess.create_subprocess_shell( cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE ) stdout, stderr = await proc.communicate() # print('cmd: {}, returncode: {}'.format(cmd, proc.returncode)) if stdout: stdout = str(stdout) # print(" 33[1;{};1m{} 33[0m".format(32, stdout)) re_result = re.findall('Escape character is', stdout) if re_result: print("