V
V
Vyacheslav Golitsyn2017-12-02 01:18:50
Python
Vyacheslav Golitsyn, 2017-12-02 01:18:50

How to ping several addresses in parallel from one python script?

I read on Habré about multithreading https://habrahabr.ru/post/149420/
The crux of the matter.
There are 10,000 addresses divided into 4 groups that need to be pinged.
How to run it in 4 threads (processes)? The goal is to get such a fork:
Script
Script into one thread (process)..
Script into one thread (process)..
Script into one thread (process)..
Split into 4 threads
| | | |
| | | |
| | | |
| | | |
Script into one thread(process)..
Script into one thread(process)..
Script into one thread(process)..
End.
Those. of the whole script, only the part with ping should go in parallel. Thanks a lot.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey, 2017-12-02
@red-barbarian

from the first example from Habr
# join threads to the main thread
t1.join()
t2.join()

R
Roman Kitaev, 2017-12-02
@deliro

aiohttp + asyncio

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question