F
F
frendri2019-07-29 23:22:36
Python
frendri, 2019-07-29 23:22:36

How to run multiple functions?

I have 2 different programs. Both have 3 functions that work endlessly. Here is the code for the first one:

thread_main = threading.Thread(target=main, name="main")
thread_set_price = threading.Thread(target=set_price, name="set_price")
thread_add = threading.Thread(target=add_to_sale, name="add_to_sale")

thread_main.start()
thread_set_price.start()
thread_add.start()

thread_main.join()
thread_set_price.join()
thread_add.join()

All 3 functions work at the same time, as they should
. And here is the code of the second program:
thread_ping = threading.Thread(target=funct.ping(key), name="ping")
thread_get_items = threading.Thread(target=funct.get_items(key), name="get_items")
thread_buy = threading.Thread(target=funct.buy(key, items), name="buy")


thread_ping.start()
thread_get_items.start()
thread_buy.start()


thread_ping.join()
thread_get_items.join()
thread_buy.join()

But for some reason only the first function is started. What could be wrong?
Moreover, if I change the code of the functions themselves in the 2nd program (For example, I will just make prints), then all of them will be executed as they should be
. UPD: I copied the functions into the file itself, now I don’t import funct and everything works, but why is that?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
perth0, 2020-02-14
@perth0

To deal with this problem, you need to send the entire code. That way I can figure out what exactly isn't working for you.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question