O
Oltmans
I've a multithreaded program in which I've to call class methods from
class methods. Here is how my code look like (excluding imports),. Any
help is highly appreciated.
#!/usr/bin/env python
class Requests(Thread):
def __init__(self, times):
Thread.__init__(self)
self.times=times
self.name=''
def run(self):
sites=['example.com','example1.com']
for i in range(0,self.times):
for site in sites:
self.name = site
self.html=SendRequest() # This line throws an error
def SendRequest(self): #A class method
# it sends a request to website using mechanize library
def startThis(times,reqs):
threads=[]
for i in range (0,reqs):
owner=Requests(times)
owner.start()
threads.append(owner)
for thread in threads:
thread.join()
if __name__=="__main__":
#I want to create 2 threads, each of them will execute twice. At
least that is the intention.
startThis(2,2)
class methods. Here is how my code look like (excluding imports),. Any
help is highly appreciated.
#!/usr/bin/env python
class Requests(Thread):
def __init__(self, times):
Thread.__init__(self)
self.times=times
self.name=''
def run(self):
sites=['example.com','example1.com']
for i in range(0,self.times):
for site in sites:
self.name = site
self.html=SendRequest() # This line throws an error
def SendRequest(self): #A class method
# it sends a request to website using mechanize library
def startThis(times,reqs):
threads=[]
for i in range (0,reqs):
owner=Requests(times)
owner.start()
threads.append(owner)
for thread in threads:
thread.join()
if __name__=="__main__":
#I want to create 2 threads, each of them will execute twice. At
least that is the intention.
startThis(2,2)