Exception in Thread:must be a sequence, not instance

Im working on python and im trying to execute a thread that takes 1 parameter "q", but when im trying to execute it a strange exception occurs, here's my code:

class Workspace(QMainWindow, Ui_MainWindow):
    """ This class is for managing the whole GUI `Workspace'.
        Currently a Workspace is similar to a MainWindow

    def __init__(self):

            from Queue import Queue, Empty
        except ImportError:
    #from queue import Queue, Empty  # python 3.x
            print "error"

        ON_POSIX = 'posix' in sys.builtin_module_names

        def enqueue_output(out, queue):
            for line in iter(out.readline, b''):

        p= Popen(["java -Xmx256m -jar bin/HelloWorld.jar"],cwd=r'/home/karen/sphinx4-1.0beta5-src/sphinx4-1.0beta5/',stdout=PIPE, shell=True, bufsize= 4024)
        q = Queue()

        t = threading.Thread(target=enqueue_output, args=(p.stdout, q))
        #t = Thread(target=enqueue_output, args=(p.stdout, q))

        t.daemon = True # thread dies with the program

# ... do other things here
        def myfunc(q):
            while True:

                try: line = q.get_nowait()
         # or q.get(timeout=.1)
                except Empty:
                else: # got line
    # ... do something with line
                    print "No esta null"
                    print line  

        thread = threading.Thread(target=myfunc, args=(q))

It fails with the following error:

Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner
  File "/usr/lib/python2.7/threading.py", line 504, in run
    self.__target(*self.__args, **self.__kwargs)
TypeError: myfunc() argument after * must be a sequence, not instance

I dont have idea what is happening! Help please!


The args parameter to threading.Thread should be a tuple and you are passing (q) which is not - it is the same as q.

I guess you wanted a 1-element tuple: you should would write (q,).

Need Your Help

how to use number picker with dialog

android dialog numberpicker

I want to use a number picker for the purpose of getting the discount percentage from the user. once the user enters the sale price, i want a dialog box to appear asking for the discount percentage...

Find the nearest/closest value in a sorted List

java logic

I was wondering if it is possible to find the closest element in a List for a element that is not there.