TypeError: Method takes takes exactly 1 argument but 2 given - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html) +--- Thread: TypeError: Method takes takes exactly 1 argument but 2 given (/thread-1233.html) |
TypeError: Method takes takes exactly 1 argument but 2 given - pras120687 - Dec-15-2016 Hi Below is my code: import SimpleHTTPServer import SocketServer import os from threading import Thread import threading class MyThread(Thread): def __init__(self,streampath): ''' Constructor. ''' Thread.__init__(self) self.streampath = streampath def __str__(self): return str(self.streampath) def run(self): #self.streampath=str(streampath) os.chdir(self.streampath) PORT = 8000 Handler = SimpleHTTPServer.SimpleHTTPRequestHandler httpd = SocketServer.TCPServer(("", PORT), Handler) print "serving at port", PORT print "function thread", threading.currentThread() httpd.serve_forever() print "test1" if __name__ == '__main__': obj1 = MyThread("C:\\\\QED") obj1.start() obj1.run("C:\\\\QED") print threading.currentThread() print('test2')The above code implementing of creation of web server using multi threading. Please observe the code in MAIN function. My main intention is to call run() method by passing argument as path. When i do that it is showing following error. Could someone helpo me where i am going wrong. My Main intention is i need to call run(streampath) by passing argument from robot framework it is showing following above error. RE: TypeError: Method takes takes exactly 1 argument but 2 given - Yoriz - Dec-15-2016 Run doesn't take any arguments and is not called directly, the start methods invokes run. https://docs.python.org/2/library/threading.html#threading.Thread.start Wrote:Start the thread’s activity. https://docs.python.org/2/library/threading.html#threading.Thread.run Wrote:Method representing the thread’s activity. |