Форум сайта python.su
Такой код:
import random import subprocess from threading import Thread results = [] start_processes = 6 def run_command(count, result_storage): cmd = str(subprocess.check_output(['ping', '-c', f'{body}', 'google.' + 'com'], text=True)) result_storage.append(cmd) threads = [] for _ in range(start_processes): ch = random.choices('1234567890', k=2) body = (''.join(ch)) print(body) t = Thread(target=run_command, args=[body, results]) t.start() threads.append(t) for t in threads: t.join()
Офлайн