TypeError: start() argument after * must be an iterable, not int

Viewed 15226

I want run some timer in thread,but it display ERRORTypeError: start() argument after * must be an iterable, not int,How can I fix it?

    while 1:
            try:
                _thread.start_new_thread(self.timer0.start,100)
                _thread.start_new_thread(self.timer1.start,150)
                _thread.start_new_thread(self.timer2.start,200)
                _thread.start_new_thread(self.timer3.start,250)
                _thread.start_new_thread(self.timer4.start,300)
                break
            except:
                print ("Error: unable to start thread")
            break
1 Answers

Check the docs: https://docs.python.org/3/library/_thread.html

_thread.start_new_thread(function, args[, kwargs])

Start a new thread and return its identifier. The thread executes the function function with the argument list args (which must be a tuple).

Thus, the correct call looks like:

_thread.start_new_thread(self.timer0.start, (100,))
Related