Code Monkey home page Code Monkey logo

Comments (2)

ValentinBELYN avatar ValentinBELYN commented on August 29, 2024

Hi @TylerIO,

There's nothing wrong with using threads to parallelize your code. icmplib also used them in versions lower than v3 before replacing them with asyncio more suitable for network operations of this nature.

Performance wise you should have something similar be it with asyncio. The differences you get are due to the fact that you are creating 10000 concurrent threads while the multiping function limits concurrent operations to 50 by default (concurrent_tasks parameter) to limit CPU usage.

Try these parameters instead (you may be limited by your CPU):

multiping(['1.1.1.1'] * 10000, count=1, concurrent_tasks=10000, privileged=False) # 10000 concurrent tasks
multiping(['1.1.1.1'] * 10000, count=1, concurrent_tasks=float('inf'), privileged=False) # infinite number of concurrent tasks

If you want to learn more about asyncio, I recommend you to read this article: https://realpython.com/async-io-python/
If you're not comfortable with them or you don't want to use the multiping function, threads may do the job just fine!

I hope I was able to help you.

from icmplib.

nudred avatar nudred commented on August 29, 2024

Thanks a lot for the answer. Once again, I repeat. Your module is amazing

from icmplib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.