Help with Queues and Threading

O

Ognjen Bezanov

Hi, all

Thanks all of you who helped me with the threading and queues issue. I
am trying to get it working but I am having problems. When I try to run
the following:


cmddata = mediaplay.initcommandqueue() #initiates the Queue to send
commands down

mediathread = threading.Thread( target=mediaplay.mainloop,
args=(cmddata) ) #starts the main loop, which will wait for a command
then execute it, Queue object passed to it.

threading.Thread.start(mediathread) # start the thread

I get the following error:
Traceback (most recent call last):
File "/usr/lib/python2.3/threading.py", line 436, in __bootstrap
self.run()
File "/usr/lib/python2.3/threading.py", line 416, in run
self.__target(*self.__args, **self.__kwargs)
TypeError: mainloop() argument after * must be a sequence



But if I run the loop directly (i.e. not using threads, just calling the
function) it works just fine. What could the problem be?
 
P

Paul Rubin

Ognjen Bezanov said:
But if I run the loop directly (i.e. not using threads, just calling the
function) it works just fine. What could the problem be?

You have to say args=(cmddata,) with the comma inside the parens,
to make a seqence instead of a parenthesized expression.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,600
Members
45,181
Latest member
RexGreenwa
Top