Skip to content
Advertisement

pass function from class without starting it python

I need to run two functions with the threading module

you’re able to do this Thread(target=my_func)

but i want the function from a class (imported class) so i tried Thread(target=a_class.my_func)

but it didn’t worked, then i tried Thread(target=a_class.my_func())

but this one starts to run the function because i called it , and this is an infinite loop so the next function would never run.

how do i supposed to do it?

Advertisement

Answer

You should wrap the class methods, like this:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement