Python: How to Multithread on a loop?

Viewed 24

Hello i want make Multithreading on a loop. But its doesnt start...

webhook_url = input(Colorate.Horizontal(Colors.blue_to_cyan, "WEBHOOK LINK $> ", 1))
msg = input(Colorate.Horizontal(Colors.blue_to_cyan, "MESSAGE $> ", 1))

def spam():
    webhook = DiscordWebhook(url=webhook_url, content=msg)
    while True:
        try:
            webhook.execute()
        except:
            print(Colorate.Horizontal(Colors.red_to_yellow, f"ERROR: CANT SEND MESSAGE", 1))
        else:
            print(Colorate.Horizontal(Colors.green_to_yellow, f"INFO: SEND MESSAGE", 

threads = list()
for index in range(5, 1):
    print(Colorate.Horizontal(Colors.green_to_yellow, f"INFO: STARTING THREAD {index}", 1))
    x = threading.Thread(target=spam(), args=(index,))
    threads.append(x)
    x.start()

So i want do 5 Threads. But its doesnt start to do it. Because this is an while True loop. So how i can do that?

0 Answers
Related