This does not call test
in a new thread:
thread = threading.Thread(target=test("Test"))
thread.start()
Here’s how Python interprets those lines of code:
- Main thread calls
test("Test")
. test("Test")
returnsNone
.- Main thread calls
Thread(target=None)
.* - Main thread starts the new thread.
- New thread does absolutely nothing at all because its target is
None
.
Edit:
*I wondered why Thread(targe=None)
does not raise an exception, but @Ahmed AEK explained it in a comment, below.