title: Threading Decorator [Python]
body: <p>i'm trying to create a simple program using python socket and threading library. I would like to automatize the following procedure using a decorator:</p>
  <pre><code>t = threading.Thread(target=function, args=(arg1, arg2))
  t.start()
  </code></pre>
  <p>the program is structured using OOP so I defined a subclass inside the main one to contain all the decorators (I've read about this method in this article: <a href="https://medium.com/@vadimpushtaev/decorator-inside-python-class-1e74d23107f6" rel="nofollow noreferrer">https://medium.com/@vadimpushtaev/decorator-inside-python-class-1e74d23107f6</a>). Therefore I have a situation like this:</p>
  <pre><code>class Server(object):
  
      class Decorators(object):
  
          @classmethod
          def threaded_decorator(cls, function):
              def inner_function():
                  function_thread = threading.Thread(target=function)
                  function_thread.start()
              return inner_function
  
      def __init__(self, other_arguments):
          # other code
          pass
  
      @Decorators.threaded_decorator
      def function_to_be_threaded(self):
          # other code
          pass
  </code></pre>
  <p>But when I try to run, I get the following error: <code>TypeError: function_to_be_threaded() missing one required argument: 'self'</code>. I suspect that the issue is located in the part when I call the threading.Thread(target=function) which somehow doesn't pass the entire function self.function_to_be_threaded. Hence, if you know how to fix this, please can you tell me?. Also, can you tell me if there is a way to implement a decorator that accepts argument which will pass to the Thread class as <code>args=(arguments_of_the_decorator)</code>?</p>
  <p>Thank very much you for your time and excuse my English, I'm still practising it</p>