Skip to content Skip to sidebar Skip to footer

Typeerror In Threading. Function Takes X Positional Argument But Y Were Given

I am working with Python at the moment. I have a start-function, that gets a string from a message. I want to start threads for every message. The thread at the moment should just

Solution 1:

The args kwarg of threading.Thread expects an iterable, and each element in that iterable is being passed to the target function.

Since you are providing a string for args: t = threading.Thread(target=startSuggestworker, args=(start_keyword))

each character is being passed as a separate argument to startSuggestworker.

Instead, you should provide args a tuple:

t = threading.Thread(target=startSuggestworker, args=(start_keyword,))
#                                                                  ^ note the comma

Post a Comment for "Typeerror In Threading. Function Takes X Positional Argument But Y Were Given"