Closed nudred closed 1 year ago
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.
Thanks a lot for the answer. Once again, I repeat. Your module is amazing
I really liked your module and decided to find the most performance code for myself. I wrote the following code:
And got the following results:
The results are amazing. But since I'm not very experienced, I'd like to know how bad it is to use Threading? What problems can I face if I use it?
I will be very grateful for the answer