This is my code:
import threading
import requests
class MyThread(threading.Thread):
def __init__(self, id):
threading.Thread.__init__(self)
self.id = id
def run(self):
print('Thread {0} is running...'.format(self.id))
req = requests.post(url='http://test.com', data={'id': id})
if req.json()['success']:
# stop other threads
print('Thread {0} is finished!'.format(self.id))
for id in range(0, 480):
t = MyThread(id)
t.start()
In every thread I send lots of requests. I want to stop other threads which are made in for loop, if the condition was true.
How to do that?!