Python3 _thread syntax

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:


Or I need to define my class different somehow:

class frontPanel:
def init(self):

Can someone help me with the syntax for this? TIA.

Have you tried using an empty tuple ()?

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:

1 Like

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.

That’s a Python 2 tutorial. You can tell because there’s print statements print "thing" instead of print calls print("thing")

Also, that tutorial discusses the threading module a little bit later, and there’s more tutorial there

Thanks, I am switching to threading.

So I am on to the next layer of the onion. I am using threading:

print(‘Front Panel Thread Started’)

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.

Perhaps it is related to my other post.

Never mind. The solution to my other post fixed this one too.