Skip to content

when multi dst_ip to ping, this library have serious performance issues #36

@sangensong

Description

@sangensong
import asyncio
from pprint import pprint

import aioping
import uvloop

asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())

async def do_ping(host, timeout=4):
    try:
        delay = await aioping.ping(host, timeout) * 1000
        return {"dst_ip": host, 'has_reply': True, 'delay': delay}

    except TimeoutError:
        return {"dst_ip": host, 'has_reply': False, 'delay': timeout*1000}


async def do_ping_task(ips, delay=4):
    return await asyncio.gather(*[do_ping(ip, delay) for ip in ips])


ttl = asyncio.run(do_ping_task(
    [
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20","10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20","10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20","10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20","10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20","10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20","10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20","10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20","10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20","10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20","10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20","10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20","10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20","10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20","10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20","10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20","10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20","10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20","10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20","10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",
        "10.223.1.87",
        "10.223.1.10",
        "10.223.1.20",

    ],
    1))
pprint(ttl)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions