title: TypeError: function takes 2 positional arguments but 3 were given
body: <p>I'm trying to create a seperate class for MQTT subscribe and publish for a LoPy device, written in micropython.</p>
  <p>This is my code of main.py:</p>
  <pre class="lang-py prettyprint-override"><code>import pycom
  import time
  import communicationmod
  
  pycom.heartbeat(False)
  
  if __name__ == '__main__':
  
      communication = communicationmod.Com()
  
      while True:
  
          communication.update()
          print (communication.getmessage())
          time.sleep(1.00)
  </code></pre>
  <p>And this is the code of communicationmod.py:</p>
  <pre class="lang-py prettyprint-override"><code>import pycom
  import time
  from umqtt import MQTTClient
  import machine
  import ujson
  
  class Com:
  
      mess = &quot;&quot;
      client = None
  
      def __init__(self):
  
          print ('init')
  
          self.client = MQTTClient(&quot;pycom&quot;, &quot;192.168.123.50&quot;, port=1883, user=&quot;simon&quot;, password=&quot;****&quot;)
          self.client.settimeout = self.settimeout
          self.client.connect()
  
          self.client.set_callback(self._recv_msg_callback)
          print ('Callback setted!')
          self.client.subscribe(&quot;/Upload&quot;)
          print ('Subsribed!')
  
      def settimeout(duration):
          pass
  
      def _recv_msg_callback(topic, msg):
          print(&quot;{}&quot;.format(msg))
  
      def update(self):
          self.client.check_msg()
          self.client.publish(&quot;/Download&quot;, &quot;this is a test string&quot;)
  
      def getmessage(self):
          return self.mess
  </code></pre>
  <p>But I get an error:</p>
  <blockquote>
  <p>File &quot;main.py&quot;, line 44, in </p>
  <p>File &quot;communicationmod.py&quot;, line 32, in update</p>
  <p>File &quot;umqtt.py&quot;, line 194, in check_msg</p>
  <p>File &quot;umqtt.py&quot;, line 181, in wait_msg</p>
  <p>TypeError: function takes 2 positional arguments but 3 were given</p>
  <p>MicroPython v1.8.6-489-g246ea51a on 2017-03-02; LoPy with ESP32</p>
  </blockquote>
  <p>The publish method works and when I put all the code of the class Com in the main.py file (without classes) the client.check_msg() works too.
  I don't understand why I'm getting this error and why it works without it is in the class.</p>
  <p><a href="https://pypi.python.org/pypi/micropython-umqtt.simple" rel="nofollow noreferrer">I use this library for MQTT</a></p>