Hello guest, if you read this it means you are not registered. Click here to register in a few simple steps, you will enjoy all features of our Forum.
Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TypeError: Method takes takes exactly 1 argument but 2 given
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. '''

       self.streampath = streampath

   def __str__(self):
       return str(self.streampath)
   def run(self):
       PORT = 8000
       Handler = SimpleHTTPServer.SimpleHTTPRequestHandler

       httpd = SocketServer.TCPServer(("", PORT), Handler)

       print "serving at port", PORT
       print "function thread", threading.currentThread()
       print "test1"

if __name__ == '__main__':

  obj1 = MyThread("C:\\\\QED")

  print threading.currentThread()
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.
TypeError: run() takes exactly 1 argument (2 given)
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.
Run doesn't take any arguments and is not called directly, the start methods invokes run.

https://docs.python.org/2/library/thread...read.start Wrote:Start the thread’s activity.
It must be called at most once per thread object. It arranges for the object’s run() method to be invoked in a separate thread of control.
This method will raise a RuntimeError if called more than once on the same thread object.

https://docs.python.org/2/library/thread...Thread.run Wrote:Method representing the thread’s activity.
You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  [Help] Keep getting a 'TypeError' from Django and BeautifulSoup Plant_Boy 7 137 Jun-13-2018, 04:13 PM
Last Post: Larz60+
  Bad Request error Method Not Allowed The method is not allowed for the requested URL. vk7 0 252 Apr-08-2018, 05:14 PM
Last Post: vk7

Forum Jump:

Users browsing this thread: 1 Guest(s)