I have a class I want to instantiate and run in a thread. My init for the class takes no arguments. When I try to start the thread it tells me I need 2 arguments and that it must be a tuple. When I put something in for that I get an error of too many arguments in init. Either I am specifying the start thread wrong:
_thread.start_new_thread(FP.frontPanel,???)
Or I need to define my class different somehow:
class frontPanel:
def init(self):
.
.
.
Can someone help me with the syntax for this? TIA.
And why are you using _thread instead of threading?
Anything with a leading underscore is normally considered private, and
if you didn’t write it yourself, you shouldn’t touch it. It’s not
entirely clear to me whether that applies to _thread. The
documentation doesn’t say anything either way:
but my rule of thumb is to treat anything with a single underscore as
private unless explicitly documented otherwise. So unless you have a
really, really good reason for using it, you should consider using the
higher-level and definitely public threading API instead:
Thanks for the reply. I guess that was a mistake. I don’t know where I got that from. Unfortunately the network to that server is down right now so I don’t know when I’ll be able to try to fix that. I’m using ‘thread’ because that is what I found a python 3 tutorial for.
I have not tried an empty tuple as it did not occur to me.
In any case I’ll investigate your link to use threading.
The target script is a tkinter GUI which comes up. However, it seems that ‘start’ is blocking as my ‘print’ is not displayed until that GUI window is closed.